Skip to content

Commit

Permalink
[Clang] Fix dependency computation for pack indexing expression
Browse files Browse the repository at this point in the history
Given `foo...[idx]` if idx is value dependent, the expression
is type dependent.

Fixes llvm#91885
Fixes llvm#91884
  • Loading branch information
cor3ntin committed May 13, 2024
1 parent d4f5cf2 commit 4cadff5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/AST/ComputeDependence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() |
Expand Down
14 changes: 14 additions & 0 deletions clang/test/SemaCXX/cxx2c-pack-indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,17 @@ void h() {
// expected-note-re@-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);
}

}

0 comments on commit 4cadff5

Please sign in to comment.