From 2719a5d7ef30908de9e140ab4fd1b01c9e11d51c Mon Sep 17 00:00:00 2001 From: Tilak Chad Date: Tue, 31 Dec 2024 21:57:50 +0545 Subject: [PATCH] [Clang] Resolved type of expression indexing into pack of values of a non-dependent type --- clang/docs/ReleaseNotes.rst | 1 + clang/lib/AST/ExprCXX.cpp | 2 +- clang/test/SemaCXX/cxx2c-pack-indexing.cpp | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 983c1da20ed4c..612541b0ddf84 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -886,6 +886,7 @@ Bug Fixes to C++ Support out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218) - Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042) - Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081) +- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index fc09d24fc30cb..5bf5d6adf525a 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -1722,7 +1722,7 @@ PackIndexingExpr *PackIndexingExpr::Create( if (Index && FullySubstituted && !SubstitutedExprs.empty()) Type = SubstitutedExprs[*Index]->getType(); else - Type = Context.DependentTy; + Type = PackIdExpr->getType(); void *Storage = Context.Allocate(totalSizeToAlloc(SubstitutedExprs.size())); diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp index cb679a6c3ad87..58b642d2735b6 100644 --- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp +++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp @@ -305,3 +305,19 @@ template struct mdispatch_ { mdispatch_ d; } // namespace GH116105 + +namespace GH121242 { + // Non-dependent type pack access + template + int y = x...[0]; + + struct X {}; + + template + X z = x...[0]; + + void foo() { + (void)y<0>; + (void)z; + } +} // namespace GH121242