@@ -17146,21 +17146,14 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
1714617146 FoldKind).isInvalid())
1714717147 Failed = true;
1714817148
17149- // If the static_assert passes, only verify that
17150- // the message is grammatically valid without evaluating it.
17151- if (!Failed && AssertMessage && Cond.getBoolValue()) {
17152- std::string Str;
17153- EvaluateStaticAssertMessageAsString(AssertMessage, Str, Context,
17154- /*ErrorOnInvalidMessage=*/false);
17155- }
17156-
1715717149 // CWG2518
1715817150 // [dcl.pre]/p10 If [...] the expression is evaluated in the context of a
1715917151 // template definition, the declaration has no effect.
1716017152 bool InTemplateDefinition =
1716117153 getLangOpts().CPlusPlus && CurContext->isDependentContext();
1716217154
1716317155 if (!Failed && !Cond && !InTemplateDefinition) {
17156+
1716417157 SmallString<256> MsgBuffer;
1716517158 llvm::raw_svector_ostream Msg(MsgBuffer);
1716617159 bool HasMessage = AssertMessage;
@@ -17192,8 +17185,8 @@ Decl *Sema::BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc,
1719217185 << InnerCond->getSourceRange();
1719317186 DiagnoseStaticAssertDetails(InnerCond);
1719417187 } else {
17195- Diag(AssertExpr->getBeginLoc() , diag::err_static_assert_failed)
17196- << !HasMessage << Msg.str() << AssertExpr->getSourceRange();
17188+ Diag(StaticAssertLoc , diag::err_static_assert_failed)
17189+ << !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
1719717190 PrintContextStack();
1719817191 }
1719917192 Failed = true;
0 commit comments