Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks %s
      2 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s
      3 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fms-extensions %s
      4 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing -fms-extensions %s
      5 
      6 namespace test_constexpr_checking {
      7 
      8 namespace ns1 {
      9   struct NonLit { ~NonLit(); };  //expected-note{{not literal}}
     10   auto L = [](NonLit NL) constexpr { }; //expected-error{{not a literal type}}
     11 } // end ns1
     12 
     13 namespace ns2 {
     14   auto L = [](int I) constexpr { asm("non-constexpr");  }; //expected-error{{not allowed in constexpr function}}
     15 } // end ns1
     16 
     17 } // end ns test_constexpr_checking
     18 
     19 namespace test_constexpr_call {
     20 
     21 namespace ns1 {
     22   auto L = [](int I) { return I; };
     23   static_assert(L(3) == 3);
     24 } // end ns1
     25 namespace ns2 {
     26   auto L = [](auto a) { return a; };
     27   static_assert(L(3) == 3);
     28   static_assert(L(3.14) == 3.14);
     29 }
     30 namespace ns3 {
     31   auto L = [](auto a) { asm("non-constexpr"); return a; }; //expected-note{{declared here}}
     32   constexpr int I =  //expected-error{{must be initialized by a constant expression}}
     33       L(3); //expected-note{{non-constexpr function}}
     34 }
     35 
     36 } // end ns test_constexpr_call