[clang] [clang] fix parsing typeid with pack index (PR #94299)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 3 19:28:12 PDT 2024
https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/94299
>From 0150bd8d4d94cc25c194722471bac8a4485f6e6e Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Tue, 4 Jun 2024 00:59:38 +0000
Subject: [PATCH 1/2] fix typeid with pack index
---
clang/lib/AST/Expr.cpp | 4 +---
clang/test/SemaCXX/GH93650.cpp | 12 ++++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
create mode 100644 clang/test/SemaCXX/GH93650.cpp
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ac0b1b38f0162..f9d634550dc06 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -3618,12 +3618,10 @@ bool Expr::HasSideEffects(const ASTContext &Ctx,
case ConceptSpecializationExprClass:
case RequiresExprClass:
case SYCLUniqueStableNameExprClass:
+ case PackIndexingExprClass:
// These never have a side-effect.
return false;
- case PackIndexingExprClass:
- return cast<PackIndexingExpr>(this)->getSelectedExpr()->HasSideEffects(
- Ctx, IncludePossibleEffects);
case ConstantExprClass:
// FIXME: Move this into the "return false;" block above.
return cast<ConstantExpr>(this)->getSubExpr()->HasSideEffects(
diff --git a/clang/test/SemaCXX/GH93650.cpp b/clang/test/SemaCXX/GH93650.cpp
new file mode 100644
index 0000000000000..cc82bd084248e
--- /dev/null
+++ b/clang/test/SemaCXX/GH93650.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+namespace std {
+struct type_info {
+ const char *name;
+};
+} // namespace std
+
+namespace GH93650_bug {
+auto func(auto... inputArgs) { return typeid(inputArgs...[0]); }
+} // namespace GH93650_bug
>From 89dc6aac54e6ff50c5d81a2f114ebce2fe9beb4f Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Tue, 4 Jun 2024 02:28:00 +0000
Subject: [PATCH 2/2] address CR comment
---
clang/test/SemaCXX/GH93650.cpp | 12 ------------
clang/test/SemaCXX/cxx2c-pack-indexing.cpp | 10 ++++++++++
2 files changed, 10 insertions(+), 12 deletions(-)
delete mode 100644 clang/test/SemaCXX/GH93650.cpp
diff --git a/clang/test/SemaCXX/GH93650.cpp b/clang/test/SemaCXX/GH93650.cpp
deleted file mode 100644
index cc82bd084248e..0000000000000
--- a/clang/test/SemaCXX/GH93650.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -std=c++2c -fsyntax-only -verify %s
-// expected-no-diagnostics
-
-namespace std {
-struct type_info {
- const char *name;
-};
-} // namespace std
-
-namespace GH93650_bug {
-auto func(auto... inputArgs) { return typeid(inputArgs...[0]); }
-} // namespace GH93650_bug
diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
index 28b9765127f4e..9ea90a4c3e30f 100644
--- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
+++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
@@ -221,3 +221,13 @@ void f( ) {
}
+
+namespace std {
+struct type_info {
+ const char *name;
+};
+} // namespace std
+
+namespace GH93650 {
+auto func(auto... inputArgs) { return typeid(inputArgs...[0]); }
+} // namespace GH93650
More information about the cfe-commits
mailing list