llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

<details>
<summary>Changes</summary>

This fixes the transformation of substituted constant template parameters by 
providing the instantiated parameter type for the function template 
specialization case.

This fixes a regression introduced in #<!-- -->161029 which will be backported 
to llvm-22, so there are no release notes.

Fixes #<!-- -->188759

---
Full diff: https://github.com/llvm/llvm-project/pull/189559.diff


2 Files Affected:

- (modified) clang/lib/AST/DeclTemplate.cpp (+6-4) 
- (added) clang/test/SemaTemplate/GH188759.cpp (+13) 


``````````diff
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 5a8e1ed445f3a..99d02fdc99e92 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1707,10 +1707,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

``````````

</details>


https://github.com/llvm/llvm-project/pull/189559
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to