xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/undefined-inline.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -verify %s
2f4a2713aSLionel Sambuc // PR14993
3f4a2713aSLionel Sambuc 
4f4a2713aSLionel Sambuc namespace test1 {
5f4a2713aSLionel Sambuc   inline void f();  // expected-warning{{inline function 'test1::f' is not defined}}
test()6f4a2713aSLionel Sambuc   void test() { f(); }  // expected-note{{used here}}
7f4a2713aSLionel Sambuc }
8f4a2713aSLionel Sambuc 
9f4a2713aSLionel Sambuc namespace test2 {
10f4a2713aSLionel Sambuc   inline int f();
test()11f4a2713aSLionel Sambuc   void test() { (void)sizeof(f()); }
12f4a2713aSLionel Sambuc }
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc namespace test3 {
15f4a2713aSLionel Sambuc   void f();  // expected-warning{{inline function 'test3::f' is not defined}}
16f4a2713aSLionel Sambuc   inline void f();
test()17f4a2713aSLionel Sambuc   void test() { f(); }  // expected-note{{used here}}
18f4a2713aSLionel Sambuc }
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc namespace test4 {
21f4a2713aSLionel Sambuc   inline void error_on_zero(int);    // expected-warning{{inline function 'test4::error_on_zero' is not defined}}
error_on_zero(char *)22f4a2713aSLionel Sambuc   inline void error_on_zero(char*) {}
test()23f4a2713aSLionel Sambuc   void test() { error_on_zero(0); }  // expected-note{{used here}}
24f4a2713aSLionel Sambuc }
25f4a2713aSLionel Sambuc 
26f4a2713aSLionel Sambuc namespace test5 {
27f4a2713aSLionel Sambuc   struct X { void f(); };
test(X & x)28f4a2713aSLionel Sambuc   void test(X &x) { x.f(); }
29f4a2713aSLionel Sambuc }
30f4a2713aSLionel Sambuc 
31f4a2713aSLionel Sambuc namespace test6 {
32f4a2713aSLionel Sambuc   struct X { inline void f(); };  // expected-warning{{inline function 'test6::X::f' is not defined}}
test(X & x)33f4a2713aSLionel Sambuc   void test(X &x) { x.f(); }  // expected-note{{used here}}
34f4a2713aSLionel Sambuc }
35f4a2713aSLionel Sambuc 
36f4a2713aSLionel Sambuc namespace test7 {
37f4a2713aSLionel Sambuc   void f();  // expected-warning{{inline function 'test7::f' is not defined}}
test()38f4a2713aSLionel Sambuc   void test() { f(); } // no used-here note.
39f4a2713aSLionel Sambuc   inline void f();
40f4a2713aSLionel Sambuc }
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc namespace test8 {
43f4a2713aSLionel Sambuc   inline void foo() __attribute__((gnu_inline));
test()44f4a2713aSLionel Sambuc   void test() { foo(); }
45f4a2713aSLionel Sambuc }
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc namespace test9 {
48f4a2713aSLionel Sambuc   void foo();
test()49f4a2713aSLionel Sambuc   void test() { foo(); }
50f4a2713aSLionel Sambuc   inline void foo() __attribute__((gnu_inline));
51f4a2713aSLionel Sambuc }
52f4a2713aSLionel Sambuc 
53f4a2713aSLionel Sambuc namespace test10 {
54f4a2713aSLionel Sambuc   inline void foo();
test()55f4a2713aSLionel Sambuc   void test() { foo(); }
56f4a2713aSLionel Sambuc   inline void foo() __attribute__((gnu_inline));
57f4a2713aSLionel Sambuc }
58*0a6a1f1dSLionel Sambuc 
59*0a6a1f1dSLionel Sambuc namespace test11 {
60*0a6a1f1dSLionel Sambuc   inline void foo() __attribute__((dllexport));
61*0a6a1f1dSLionel Sambuc   inline void bar() __attribute__((dllimport));
test()62*0a6a1f1dSLionel Sambuc   void test() { foo(); bar(); }
63*0a6a1f1dSLionel Sambuc }
64