release/22.x: [clang] fix getReplacedTemplateParameter for function template specializations (#189559)#189596
Open
llvmbot wants to merge 1 commit intollvm:release/22.xfrom
Open
release/22.x: [clang] fix getReplacedTemplateParameter for function template specializations (#189559)#189596llvmbot wants to merge 1 commit intollvm:release/22.xfrom
llvmbot wants to merge 1 commit intollvm:release/22.xfrom
Conversation
…lizations (llvm#189559) (cherry picked from commit 2b43932)
Member
Author
|
@zyn0217 What do you think about merging this PR to the release branch? |
Member
Author
|
@llvm/pr-subscribers-clang Author: llvmbot ChangesBackport 2b43932 Requested by: @zyn0217 Full diff: https://github.com/llvm/llvm-project/pull/189596.diff 2 Files Affected:
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index ed20c720ce06c..4e77a2c4686eb 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1713,10 +1713,12 @@ clang::getReplacedTemplateParameter(Decl *D, unsigned Index) {
case Decl::Kind::CXXConstructor:
case Decl::Kind::CXXDestructor:
case Decl::Kind::CXXMethod:
- case Decl::Kind::Function:
- return getReplacedTemplateParameter(
- cast<FunctionDecl>(D)->getTemplateSpecializationInfo()->getTemplate(),
- Index);
+ case Decl::Kind::Function: {
+ const FunctionTemplateSpecializationInfo *Info =
+ cast<FunctionDecl>(D)->getTemplateSpecializationInfo();
+ return {Info->getTemplate()->getTemplateParameters()->getParam(Index),
+ Info->TemplateArguments->asArray()[Index]};
+ }
default:
llvm_unreachable("Unhandled templated declaration kind");
}
diff --git a/clang/test/SemaTemplate/GH188759.cpp b/clang/test/SemaTemplate/GH188759.cpp
new file mode 100644
index 0000000000000..f0d579d1fc3e5
--- /dev/null
+++ b/clang/test/SemaTemplate/GH188759.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++26 %s
+
+namespace t1 {
+ template <int> struct integer_sequence {};
+ template <int> struct array {};
+ template <int ARRAY_SIZE, array<ARRAY_SIZE> test_apdus> void runBlobs() {
+ []<int... INDEX>(integer_sequence<INDEX...>) { // expected-note {{requested here}}
+ int x{operator0<test_apdus, INDEX>()...};
+ // expected-error@-1 {{use of undeclared identifier 'operator0'}}
+ }(integer_sequence<1>{});
+ }
+ template void runBlobs<2, {}>(); // expected-note {{requested here}}
+} // namespace t1
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport 2b43932
Requested by: @zyn0217