diff options
author | Younan Zhang <zyn7109@gmail.com> | 2024-05-01 11:52:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-01 11:52:14 +0800 |
commit | 410d6350eda322de213941b36adcdab13a0b557b (patch) | |
tree | dac571fb3f78d843a2dc374e59ab0bb43a4c45f3 /clang/lib/AST/ExprClassification.cpp | |
parent | 306ae14face205e1bf2557ca2443c781b1d862f5 (diff) | |
download | llvm-410d6350eda322de213941b36adcdab13a0b557b.zip llvm-410d6350eda322de213941b36adcdab13a0b557b.tar.gz llvm-410d6350eda322de213941b36adcdab13a0b557b.tar.bz2 |
[Sema] Avoid an undesired pack expansion while transforming PackIndexingType (#90195)
A pack indexing type can appear in a larger pack expansion, e.g
`Pack...[pack_of_indexes]...` so we need to temporarily disable
substitution of pack elements.
Besides, this patch also fixes an assertion failure in
`PackIndexingExpr::classify`: dependent `PackIndexingExpr`s are always
LValues and thus we don't need to consider their `IndexExpr`s.
Fixes https://github.com/llvm/llvm-project/issues/88925
---------
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
Diffstat (limited to 'clang/lib/AST/ExprClassification.cpp')
-rw-r--r-- | clang/lib/AST/ExprClassification.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp index 2bb8f9a..390000e3 100644 --- a/clang/lib/AST/ExprClassification.cpp +++ b/clang/lib/AST/ExprClassification.cpp @@ -216,8 +216,13 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { return ClassifyInternal(Ctx, cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement()); - case Expr::PackIndexingExprClass: + case Expr::PackIndexingExprClass: { + // A pack-index-expression always expands to an id-expression. + // Consider it as an LValue expression. + if (cast<PackIndexingExpr>(E)->isInstantiationDependent()) + return Cl::CL_LValue; return ClassifyInternal(Ctx, cast<PackIndexingExpr>(E)->getSelectedExpr()); + } // C, C++98 [expr.sub]p1: The result is an lvalue of type "T". // C++11 (DR1213): in the case of an array operand, the result is an lvalue |