return-noreturn.cpp revision 6e40035988965340555c942d6e7afb6c7527beb1
1// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code 2 3// A destructor may be marked noreturn and should still influence the CFG. 4void pr6884_abort() __attribute__((noreturn)); 5 6struct pr6884_abort_struct { 7 pr6884_abort_struct() {} 8 ~pr6884_abort_struct() __attribute__((noreturn)) { pr6884_abort(); } 9}; 10 11int pr6884_f(int x) { 12 switch (x) { default: pr6884_abort(); } 13} 14 15int pr6884_g(int x) { 16 switch (x) { default: pr6884_abort_struct(); } 17} 18 19int pr6884_g_positive(int x) { 20 switch (x) { default: ; } 21} // expected-warning {{control reaches end of non-void function}} 22 23int pr6884_h(int x) { 24 switch (x) { 25 default: { 26 pr6884_abort_struct a; 27 } 28 } 29} 30 31// PR9380 32struct PR9380 { 33 ~PR9380(); 34}; 35struct PR9380_B : public PR9380 { 36 PR9380_B( const PR9380& str ); 37}; 38void test_PR9380(const PR9380& aKey) { 39 const PR9380& flatKey = PR9380_B(aKey); 40} 41 42// Array of objects with destructors. This is purely a coverage test case. 43void test_array() { 44 PR9380 a[2]; 45} 46 47// Test classes wrapped in typedefs. This is purely a coverage test case 48// for CFGImplictDtor::getDestructorDecl(). 49void test_typedefs() { 50 typedef PR9380 PR9380_Ty; 51 PR9380_Ty test; 52 PR9380_Ty test2[20]; 53} 54 55// PR9412 - Handle CFG traversal with null successors. 56enum PR9412_MatchType { PR9412_Exact }; 57 58template <PR9412_MatchType type> int PR9412_t() { 59 switch (type) { 60 case PR9412_Exact: 61 default: 62 break; 63 } 64} // expected-warning {{control reaches end of non-void function}} 65 66void PR9412_f() { 67 PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}} 68} 69 70