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