Builder.defineMacro("__cpp_user_defined_literals", "200809L");
Builder.defineMacro("__cpp_lambdas", "200907L");
Builder.defineMacro("__cpp_constexpr",
+ LangOpts.CPlusPlus2a ? "201907L" :
LangOpts.CPlusPlus17 ? "201603L" :
LangOpts.CPlusPlus14 ? "201304L" : "200704");
Builder.defineMacro("__cpp_range_based_for",
return false;
return true;
+ case Stmt::GCCAsmStmtClass:
+ case Stmt::MSAsmStmtClass:
+ // C++2a allows inline assembly statements.
case Stmt::CXXTryStmtClass:
if (Cxx2aLoc.isInvalid())
Cxx2aLoc = S->getBeginLoc();
}
// or a compound-statement that does not contain [CXX1Y]
-constexpr int DisallowedStmtsCXX1Y_1() {
+constexpr int DisallowedStmtsCXX1Y_1(bool b) {
// - an asm-definition
- asm("int3"); // expected-error {{statement not allowed in constexpr function}}
+ if (b)
+ asm("int3");
+#if !defined(CXX2A)
+ // expected-error@-2 {{use of this statement in a constexpr function is a C++2a extension}}
+#endif
return 0;
}
constexpr int DisallowedStmtsCXX1Y_2() {
#error "wrong value for __cpp_lambdas"
#endif
-#if check(constexpr, 0, 200704, 201304, 201603, 201603)
+#if check(constexpr, 0, 200704, 201304, 201603, 201907)
#error "wrong value for __cpp_constexpr"
#endif
} // end ns1
namespace ns2 {
- auto L = [](int I) constexpr { asm("non-constexpr"); }; //expected-error{{not allowed in constexpr function}}
+ auto L = [](int I) constexpr { if (I == 5) asm("non-constexpr"); };
+#if __cpp_constexpr < 201907L
+ //expected-error@-2{{use of this statement in a constexpr function is a C++2a extension}}
+#endif
} // end ns1
// This is not constexpr until C++20, as the requirements on constexpr