[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / warn-missing-noreturn.cpp
blob618229af207e7c86ce087a9b01edda4195244392
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn -Wreturn-type
2 void f() __attribute__((noreturn));
4 template<typename T> void g(T) {
5 f();
8 template void g<int>(int);
10 template<typename T> struct A {
11 void g() {
12 f();
16 template struct A<int>;
18 struct B {
19 template<typename T> void g(T) {
20 f();
24 template void B::g<int>(int);
26 // We don't want a warning here.
27 struct X {
28 virtual void g() { f(); }
31 namespace test1 {
32 bool condition();
34 // We don't want a warning here.
35 void foo() {
36 while (condition()) {}
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;
49 void f_R7880658(R7880658 f, R7880658 l) { // no-warning
50 for (; f != l; ++f) {
54 namespace test2 {
56 bool g();
57 void *h() __attribute__((noreturn));
58 void *j();
60 struct A {
61 void *f;
63 A() : f(0) { }
64 A(int) : f(h()) { } // expected-warning {{function 'A' could be declared with attribute 'noreturn'}}
65 A(char) : f(j()) { }
66 A(bool b) : f(b ? h() : j()) { }
70 namespace test3 {
71 struct A {
72 ~A();
75 struct B {
76 ~B() { }
78 A a;
81 struct C : A {
82 ~C() { }
86 // <rdar://problem/8875247> - Properly handle CFGs with destructors.
87 struct rdar8875247 {
88 ~rdar8875247 ();
90 void rdar8875247_aux();
92 int rdar8875247_test() {
93 rdar8875247 f;
94 } // expected-warning{{non-void function does not return a value}}
96 struct rdar8875247_B {
97 rdar8875247_B();
98 ~rdar8875247_B();
101 rdar8875247_B test_rdar8875247_B() {
102 rdar8875247_B f;
103 return f;
104 } // no-warning
106 namespace PR10801 {
107 struct Foo {
108 void wibble() __attribute((__noreturn__));
111 struct Bar {
112 void wibble();
115 template <typename T> void thingy(T thing) {
116 thing.wibble();
119 void test() {
120 Foo f;
121 Bar b;
122 thingy(f);
123 thingy(b);