[clang] aa22d44 - [Clang] Do not try to diagnose parameter packs in invalid pack expressions (#89257)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 21 02:43:55 PDT 2024
Author: cor3ntin
Date: 2024-04-21T11:43:51+02:00
New Revision: aa22d4422ee031d3867290e6ec12985f87d9ea2f
URL: https://github.com/llvm/llvm-project/commit/aa22d4422ee031d3867290e6ec12985f87d9ea2f
DIFF: https://github.com/llvm/llvm-project/commit/aa22d4422ee031d3867290e6ec12985f87d9ea2f.diff
LOG: [Clang] Do not try to diagnose parameter packs in invalid pack expressions (#89257)
In a pack expression, if the id-expression is not valid, do no try to
detect whether it is a pack as that would lead to a crash trying to
print a recovery expression.
Fixes #88929
Added:
Modified:
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/test/SemaCXX/cxx2c-pack-indexing.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 4909414c0c78d4..a4b681ae4f008e 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1085,9 +1085,11 @@ ExprResult Sema::ActOnPackIndexingExpr(Scope *S, Expr *PackExpression,
SourceLocation RSquareLoc) {
bool isParameterPack = ::isParameterPack(PackExpression);
if (!isParameterPack) {
- CorrectDelayedTyposInExpr(IndexExpr);
- Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
- << PackExpression;
+ if (!PackExpression->containsErrors()) {
+ CorrectDelayedTyposInExpr(IndexExpr);
+ Diag(PackExpression->getBeginLoc(), diag::err_expected_name_of_pack)
+ << PackExpression;
+ }
return ExprError();
}
ExprResult Res =
diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
index e13635383b6ca6..606715e6aacffd 100644
--- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
+++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
@@ -154,3 +154,9 @@ void f() {
}
}
+
+namespace GH88929 {
+ bool b = a...[0]; // expected-error {{use of undeclared identifier 'a'}}
+ using E = P...[0]; // expected-error {{unknown type name 'P'}} \
+ // expected-error {{expected ';' after alias declaration}}
+}
More information about the cfe-commits
mailing list