Home | History | Annotate | Download | only in SemaCXX
      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.
      4 void pr6884_abort() __attribute__((noreturn));
      5 
      6 struct pr6884_abort_struct {
      7   pr6884_abort_struct() {}
      8   ~pr6884_abort_struct() __attribute__((noreturn)) { pr6884_abort(); }
      9 };
     10 
     11 int pr6884_f(int x) {
     12   switch (x) { default: pr6884_abort(); }
     13 }
     14 
     15 int pr6884_g(int x) {
     16   switch (x) { default: pr6884_abort_struct(); }
     17 }
     18 
     19 int pr6884_g_positive(int x) {
     20   switch (x) { default: ; }
     21 } // expected-warning {{control reaches end of non-void function}}
     22 
     23 int pr6884_h(int x) {
     24   switch (x) {
     25     default: {
     26       pr6884_abort_struct a;
     27     }
     28   }
     29 }
     30 
     31 // PR9380
     32 struct PR9380 {
     33   ~PR9380();
     34 };
     35 struct PR9380_B : public PR9380 {
     36   PR9380_B( const PR9380& str );
     37 };
     38 void 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.
     43 void 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().
     49 void 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.
     56 enum PR9412_MatchType { PR9412_Exact };
     57 
     58 template <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 
     66 void PR9412_f() {
     67     PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}}
     68 }
     69 
     70