[PATCH] D106093: SubstTemplateTypeParmType can contain an 'auto' type in their replacement type

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 16 05:36:13 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ada884cbc2f: SubstTemplateTypeParmType can contain an 'auto' type in their replacement type (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D106093?vs=359101&id=359293#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106093

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/crash-auto-36064.cpp


Index: clang/test/SemaCXX/crash-auto-36064.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/crash-auto-36064.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+template <typename A, decltype(new A)> // expected-error{{new expression for type 'auto' requires a constructor argument}}
+struct b;
+struct d {
+  static auto c = ;              // expected-error{{expected expression}}
+  decltype(b<decltype(c), int>); // expected-error{{expected '(' for function-style cast or type construction}}
+                                 // expected-note at -1{{while substituting prior template arguments into non-type template parameter [with A = auto]}}
+};
Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -1801,6 +1801,9 @@
     }
 
     // Only these types can contain the desired 'auto' type.
+    Type *VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
+      return Visit(T->getReplacementType());
+    }
 
     Type *VisitElaboratedType(const ElaboratedType *T) {
       return Visit(T->getNamedType());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106093.359293.patch
Type: text/x-patch
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210716/4277c292/attachment.bin>


More information about the cfe-commits mailing list