Richard, it looks like this will also fix:
https://github.com/llvm/llvm-project/issues/56864
-Original Message-
From: cfe-commits On Behalf Of Richard
Smith via cfe-commits
Sent: Thursday, August 4, 2022 5:08 PM
To: cfe-commits@lists.llvm.org
Subject: [clang] 73b62f8 - Fix parsing of comma fold-expressions as the operand
of a C-style cast.
Author: Richard Smith
Date: 2022-08-04T17:08:08-07:00
New Revision: 73b62f813550b602f189afc3a60b0b39ae89f16d
URL:
https://github.com/llvm/llvm-project/commit/73b62f813550b602f189afc3a60b0b39ae89f16d
DIFF:
https://github.com/llvm/llvm-project/commit/73b62f813550b602f189afc3a60b0b39ae89f16d.diff
LOG: Fix parsing of comma fold-expressions as the operand of a C-style cast.
Added:
Modified:
clang/lib/Parse/ParseExpr.cpp
clang/test/Parser/cxx1z-fold-expressions.cpp
Removed:
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index a6a946d7f31b1..52d4938b1ecfc 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3469,7 +3469,9 @@ Parser::ParseSimpleExpressionList(SmallVectorImpl
&Exprs,
Exprs.push_back(Expr.get());
-if (Tok.isNot(tok::comma))
+// We might be parsing the LHS of a fold-expression. If we reached the fold
+// operator, stop.
+if (Tok.isNot(tok::comma) || NextToken().is(tok::ellipsis))
return false;
// Move to the next argument, remember where the comma was.
diff --git a/clang/test/Parser/cxx1z-fold-expressions.cpp
b/clang/test/Parser/cxx1z-fold-expressions.cpp
index 93ee6f20ffc6d..ac27111697737 100644
--- a/clang/test/Parser/cxx1z-fold-expressions.cpp
+++ b/clang/test/Parser/cxx1z-fold-expressions.cpp
@@ -41,7 +41,13 @@ template void as_operand_of_cast(int a, T
...t) {
(int)(t + ... + undeclared_junk) + // expected-error {{undeclared}}
(int)(... + undeclared_junk) + // expected-error {{undeclared}}
expected-error {{does not contain any unexpanded}}
(int)(undeclared_junk + ...) + // expected-error {{undeclared}}
-(int)(a + ...); // expected-error {{does not contain any unexpanded}}
+(int)(a + ...) + // expected-error {{does not contain any unexpanded}}
+(int)(a, ...) + // expected-error {{does not contain any unexpanded}}
+(int)(..., a) + // expected-error {{does not contain any unexpanded}}
+(int)(a, ..., undeclared_junk) + // expected-error {{undeclared}}
expected-error {{does not contain any unexpanded}}
+(int)(t, ...) +
+(int)(..., t) +
+(int)(t, ..., a);
}
// fold-operator can be '>' or '>>'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits