aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp b/contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp
index c1e09db2b3ee..d9ff6c42c502 100644
--- a/contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/contrib/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1016,10 +1016,23 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd) {
return nullptr;
}
- if (isTokenStringLiteral())
- AssertMessage = ParseUnevaluatedStringLiteralExpression();
- else if (getLangOpts().CPlusPlus26)
+ bool ParseAsExpression = false;
+ if (getLangOpts().CPlusPlus26) {
+ for (unsigned I = 0;; ++I) {
+ const Token &T = GetLookAheadToken(I);
+ if (T.is(tok::r_paren))
+ break;
+ if (!tok::isStringLiteral(Tok.getKind())) {
+ ParseAsExpression = true;
+ break;
+ }
+ }
+ }
+
+ if (ParseAsExpression)
AssertMessage = ParseConstantExpressionInExprEvalContext();
+ else if (tok::isStringLiteral(Tok.getKind()))
+ AssertMessage = ParseUnevaluatedStringLiteralExpression();
else {
Diag(Tok, diag::err_expected_string_literal)
<< /*Source='static_assert'*/ 1;