SubstTemplateTypeParmType can contain an 'auto' type in their replacement type

This fixes bug 36064

Differential Revision: https://reviews.llvm.org/D106093
This commit is contained in:
serge-sans-paille 2021-07-15 21:55:22 +02:00
parent 09c9f4dc7d
commit 8ada884cbc
2 changed files with 11 additions and 0 deletions

View File

@ -1801,6 +1801,9 @@ namespace {
}
// 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());

View File

@ -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@-1{{while substituting prior template arguments into non-type template parameter [with A = auto]}}
};