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@-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());
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@-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());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits