llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Hrólf Kraki (Serosh-commits)

<details>
<summary>Changes</summary>

When an invalid template parameter list is encountered while partially ordering 
template template arguments, finishing deduction can produce 
`NonDeducedMismatch` so treating this as a failed match instead of asserting 
that the template-template parameter is invalid
Fixes #<!-- -->227649

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+2-4) 
- (added) clang/test/SemaTemplate/gh227649.cpp (+6) 


``````````diff
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1544fd56b82ae2..651114329d4e9e 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6609,11 +6609,9 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
   case TemplateDeductionResult::Success:
     return true;
 
-  // It doesn't seem possible to get a non-deduced mismatch when partial
-  // ordering TTPs, except with an invalid template parameter list which has
-  // a parameter after a pack.
+  // An invalid template parameter list can produce a non-deduced mismatch
+  // while finishing the deduction.
   case TemplateDeductionResult::NonDeducedMismatch:
-    assert(PArg->isInvalidDecl() && "Unexpected NonDeducedMismatch");
     return false;
 
   // Substitution failures should have already been diagnosed.
diff --git a/clang/test/SemaTemplate/gh227649.cpp 
b/clang/test/SemaTemplate/gh227649.cpp
new file mode 100644
index 00000000000000..02784971cb6907
--- /dev/null
+++ b/clang/test/SemaTemplate/gh227649.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
+// CHECK: error: use of undeclared identifier 'foo'
+
+template <template <decltype(foo())> typename> struct S {};
+template <int &p> struct P;
+S<P> s;

``````````

</details>


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

Reply via email to