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

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 15 13:08:18 PDT 2021


serge-sans-paille created this revision.
serge-sans-paille added reviewers: rsmith, aaron.ballman.
Herald added a subscriber: kristof.beyls.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes bug 36064


Repository:
  rG LLVM Github Monorepo

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(SubstTemplateTypeParmType const *T) {
+      return Visit(T->getReplacementType());
+    }
 
     Type *VisitElaboratedType(const ElaboratedType *T) {
       return Visit(T->getNamedType());


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


More information about the cfe-commits mailing list