[clang] [Clang] Fix dependency computation for pack indexing expression (PR #91933)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 13 06:38:49 PDT 2024
================
@@ -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;
----------------
RungeCC wrote:
The change seems reasonable to me, however with it we need to alter the way `PackIndexingExpr` is handled inside the `getDecltypeForExpr`, since when 1) `E` is not type-dependent (`int...` case) and 2) `index` is instantiation-dependent we shall not directly call `getSelectedExpr`.
https://github.com/llvm/llvm-project/blob/ad1a65fcacda8794e2f1fa3e1dec1c1b7813422c/clang/lib/Sema/SemaType.cpp#L9739-L9748
https://github.com/llvm/llvm-project/blob/ad1a65fcacda8794e2f1fa3e1dec1c1b7813422c/clang/include/clang/AST/ExprCXX.h#L4411-L4415
In short, crash on the following code:
```c++
template<int...args> // notice the "int..." here.
void test(){
[&]<int idx>(){
using R = decltype( args...[idx] ) ;
}.template operator()<0>();
}
void f( ) {
test<1>();
}
```
https://github.com/llvm/llvm-project/pull/91933
More information about the cfe-commits
mailing list