[PATCH] D136259: Fix crash in constraining partial specialization on nested template.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 20 01:46:33 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c87e12484b3: Fix crash in constraining partial specialization on nested template. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136259/new/

https://reviews.llvm.org/D136259

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaTemplate/concepts-GH53354.cpp


Index: clang/test/SemaTemplate/concepts-GH53354.cpp
===================================================================
--- /dev/null
+++ 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> {};
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5803,8 +5803,8 @@
   }
 
   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>::


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136259.469134.patch
Type: text/x-patch
Size: 1170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221020/bb62982e/attachment.bin>


More information about the cfe-commits mailing list