1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn -Wreturn-type 2 void f() __attribute__((noreturn)); 3 g(T)4template<typename T> void g(T) { 5 f(); 6 } 7 8 template void g<int>(int); 9 10 template<typename T> struct A { gA11 void g() { 12 f(); 13 } 14 }; 15 16 template struct A<int>; 17 18 struct B { gB19 template<typename T> void g(T) { 20 f(); 21 } 22 }; 23 24 template void B::g<int>(int); 25 26 // We don't want a warning here. 27 struct X { gX28 virtual void g() { f(); } 29 }; 30 31 namespace test1 { 32 bool condition(); 33 34 // We don't want a warning here. foo()35 void foo() { 36 while (condition()) {} 37 } 38 } 39 40 41 // <rdar://problem/7880658> - This test case previously had a false "missing return" 42 // warning. 43 struct R7880658 { 44 R7880658 &operator++(); 45 bool operator==(const R7880658 &) const; 46 bool operator!=(const R7880658 &) const; 47 }; 48 f_R7880658(R7880658 f,R7880658 l)49void f_R7880658(R7880658 f, R7880658 l) { // no-warning 50 for (; f != l; ++f) { 51 } 52 } 53 54 namespace test2 { 55 56 bool g(); 57 void *h() __attribute__((noreturn)); 58 void *j(); 59 60 struct A { 61 void *f; 62 Atest2::A63 A() : f(0) { } Atest2::A64 A(int) : f(h()) { } // expected-warning {{function 'A' could be declared with attribute 'noreturn'}} Atest2::A65 A(char) : f(j()) { } Atest2::A66 A(bool b) : f(b ? h() : j()) { } 67 }; 68 } 69 70 namespace test3 { 71 struct A { 72 ~A(); 73 }; 74 75 struct B { ~Btest3::B76 ~B() { } 77 78 A a; 79 }; 80 81 struct C : A { ~Ctest3::C82 ~C() { } 83 }; 84 } 85 86 // <rdar://problem/8875247> - Properly handle CFGs with destructors. 87 struct rdar8875247 { 88 ~rdar8875247 (); 89 }; 90 void rdar8875247_aux(); 91 rdar8875247_test()92int rdar8875247_test() { 93 rdar8875247 f; 94 } // expected-warning{{control reaches end of non-void function}} 95 96 struct rdar8875247_B { 97 rdar8875247_B(); 98 ~rdar8875247_B(); 99 }; 100 test_rdar8875247_B()101rdar8875247_B test_rdar8875247_B() { 102 rdar8875247_B f; 103 return f; 104 } // no-warning 105 106 namespace PR10801 { 107 struct Foo { 108 void wibble() __attribute((__noreturn__)); 109 }; 110 111 struct Bar { 112 void wibble(); 113 }; 114 thingy(T thing)115 template <typename T> void thingy(T thing) { 116 thing.wibble(); 117 } 118 test()119 void test() { 120 Foo f; 121 Bar b; 122 thingy(f); 123 thingy(b); 124 } 125 } 126