Index: lib/Parse/ParseDeclCXX.cpp =================================================================== --- lib/Parse/ParseDeclCXX.cpp +++ lib/Parse/ParseDeclCXX.cpp @@ -819,7 +819,10 @@ /// ParseStaticAssertDeclaration - Parse C++0x or C11 static_assert-declaration. /// -/// [C++0x] static_assert-declaration: +/// [C++17] static_assert-declaration: +/// static_assert ( constant-expression ) ; +/// +/// [C++11] static_assert-declaration: /// static_assert ( constant-expression , string-literal ) ; /// /// [C11] static_assert-declaration: Index: lib/Sema/SemaDeclCXX.cpp =================================================================== --- lib/Sema/SemaDeclCXX.cpp +++ lib/Sema/SemaDeclCXX.cpp @@ -13736,9 +13736,16 @@ if (!Failed && !Cond) { SmallString<256> MsgBuffer; - llvm::raw_svector_ostream Msg(MsgBuffer); - if (AssertMessage) - AssertMessage->printPretty(Msg, nullptr, getPrintingPolicy()); + { + llvm::raw_svector_ostream Msg(MsgBuffer); + if (AssertMessage) + AssertMessage->printPretty(Msg, nullptr, getPrintingPolicy()); + else { + AssertExpr->printPretty(Msg, nullptr, getPrintingPolicy()); + MsgBuffer.insert(MsgBuffer.begin(), '\"'); + MsgBuffer.append(1, '\"'); + } + } Expr *InnerCond = nullptr; std::string InnerCondDescription; @@ -13747,11 +13754,12 @@ /*AllowTopLevelCond=*/false); if (InnerCond) { Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed) - << InnerCondDescription << !AssertMessage - << Msg.str() << InnerCond->getSourceRange(); + << InnerCondDescription << MsgBuffer.empty() << MsgBuffer.str() + << InnerCond->getSourceRange(); } else { Diag(StaticAssertLoc, diag::err_static_assert_failed) - << !AssertMessage << Msg.str() << AssertExpr->getSourceRange(); + << MsgBuffer.empty() << MsgBuffer.str() + << AssertExpr->getSourceRange(); } Failed = true; } Index: test/SemaCXX/static-assert-cxx17.cpp =================================================================== --- /dev/null +++ test/SemaCXX/static-assert-cxx17.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s + +static_assert(false, "foo"); // expected-error {{static_assert failed "foo"}} +static_assert(false == true); // expected-error {{static_assert failed "false == true"}} +static_assert(false, "foo \"bar\" baz"); // expected-error {{static_assert failed "foo \"bar\" baz"}} Index: test/SemaCXX/static-assert.cpp =================================================================== --- test/SemaCXX/static-assert.cpp +++ test/SemaCXX/static-assert.cpp @@ -50,7 +50,7 @@ StaticAssertProtected sap2; // expected-note {{instantiation}} static_assert(true); // expected-warning {{C++17 extension}} -static_assert(false); // expected-error-re {{failed{{$}}}} expected-warning {{extension}} +static_assert(false); // expected-error {{static_assert failed "false"}} expected-warning {{C++17 extension}} // Diagnostics for static_assert with multiple conditions