[clang] [Clang] Fix dependency computation for pack indexing expression (PR #91933)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 13 05:24:52 PDT 2024
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/91933
>From 4cadff527e02ae03aa5850ee713fe57aee663a52 Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Mon, 13 May 2024 10:00:19 +0200
Subject: [PATCH 1/2] [Clang] Fix dependency computation for pack indexing
expression
Given `foo...[idx]` if idx is value dependent, the expression
is type dependent.
Fixes #91885
Fixes #91884
---
clang/lib/AST/ComputeDependence.cpp | 3 +++
clang/test/SemaCXX/cxx2c-pack-indexing.cpp | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp
index bad8e75b2f878..ee56c50d76512 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -376,6 +376,9 @@ ExprDependence clang::computeDependence(PackExpansionExpr *E) {
ExprDependence clang::computeDependence(PackIndexingExpr *E) {
ExprDependence D = E->getIndexExpr()->getDependence();
+ if (D & ExprDependence::Value)
+ D |= ExprDependence::TypeInstantiation;
+
ArrayRef<Expr *> Exprs = E->getExpressions();
if (Exprs.empty())
D |= (E->getPackIdExpression()->getDependence() |
diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
index a3e5a0931491b..764f6163710bd 100644
--- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
+++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
@@ -194,3 +194,17 @@ void h() {
// expected-note-re at -2 {{function template specialization '{{.*}}' requested here}}
}
}
+
+namespace GH91885 {
+
+void test(auto...args){
+ [&]<int idx>(){
+ using R = decltype( args...[idx] ) ;
+ }.template operator()<0>();
+}
+
+void f( ) {
+ test(1);
+}
+
+}
>From 7c9192cffe099fe4a35e8cb9a88ec56b4480daa1 Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Mon, 13 May 2024 14:24:34 +0200
Subject: [PATCH 2/2] address review feedback
---
clang/lib/AST/ComputeDependence.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp
index ee56c50d76512..bd0519a1787cc 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -377,7 +377,7 @@ ExprDependence clang::computeDependence(PackExpansionExpr *E) {
ExprDependence clang::computeDependence(PackIndexingExpr *E) {
ExprDependence D = E->getIndexExpr()->getDependence();
if (D & ExprDependence::Value)
- D |= ExprDependence::TypeInstantiation;
+ D |= E->getPackIdExpression()->getDependence() & ExprDependence::Type;
ArrayRef<Expr *> Exprs = E->getExpressions();
if (Exprs.empty())
More information about the cfe-commits
mailing list