[clang] 4c87e12 - Fix crash in constraining partial specialization on nested template.
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 20 01:46:27 PDT 2022
Author: Utkarsh Saxena
Date: 2022-10-20T10:46:18+02:00
New Revision: 4c87e12484b39409f4d3c02e2c99042c67a76132
URL: https://github.com/llvm/llvm-project/commit/4c87e12484b39409f4d3c02e2c99042c67a76132
DIFF: https://github.com/llvm/llvm-project/commit/4c87e12484b39409f4d3c02e2c99042c67a76132.diff
LOG: Fix crash in constraining partial specialization on nested template.
Fixes: https://github.com/llvm/llvm-project/issues/53354
Differential Revision: https://reviews.llvm.org/D136259
Added:
clang/test/SemaTemplate/concepts-GH53354.cpp
Modified:
clang/lib/Sema/SemaTemplateDeduction.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0572a663561c7..a731ff674f882 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5803,8 +5803,8 @@ struct MarkUsedTemplateParameterVisitor :
}
bool TraverseTemplateName(TemplateName Template) {
- if (auto *TTP =
- dyn_cast<TemplateTemplateParmDecl>(Template.getAsTemplateDecl()))
+ if (auto *TTP = llvm::dyn_cast_or_null<TemplateTemplateParmDecl>(
+ Template.getAsTemplateDecl()))
if (TTP->getDepth() == Depth)
Used[TTP->getIndex()] = true;
RecursiveASTVisitor<MarkUsedTemplateParameterVisitor>::
diff --git a/clang/test/SemaTemplate/concepts-GH53354.cpp b/clang/test/SemaTemplate/concepts-GH53354.cpp
new file mode 100644
index 0000000000000..4fdf8bdd712a4
--- /dev/null
+++ b/clang/test/SemaTemplate/concepts-GH53354.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// expected-no-diagnostics
+
+template <template <class> class>
+struct S
+{};
+
+template <class T>
+concept C1 = requires
+{
+ typename S<T::template value_types>;
+};
+
+template <class T>
+requires C1<T>
+struct A {};
+
+template <class T>
+requires C1<T> && true
+struct A<T> {};
More information about the cfe-commits
mailing list