From: Nico Weber Date: Tue, 30 Dec 2014 02:06:40 +0000 (+0000) Subject: Don't crash on an invalid trailing return type on a function before a '...' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b4e9000961eb9c45e324b3cb93d4687d0c6e8ed0;p=clang Don't crash on an invalid trailing return type on a function before a '...' clang tries to produce a helpful diagnostic for the traiilng '...', but the code that r216778 added for this doesn't expect an invalid trailing return type. Add code to explicitly handle this. Having explicit code for this but not for other things looks a bit strange, but trailing return types are special in that they have a separate existence bit in addition to the type (see r158348). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224974 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index f5883e429d..e4fab71d99 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -782,11 +782,11 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) { Chunk.Fun.NoexceptExpr->containsUnexpandedParameterPack()) return true; - if (Chunk.Fun.hasTrailingReturnType() && - Chunk.Fun.getTrailingReturnType() - .get() - ->containsUnexpandedParameterPack()) - return true; + if (Chunk.Fun.hasTrailingReturnType()) { + QualType T = Chunk.Fun.getTrailingReturnType().get(); + if (!T.isNull() && T->containsUnexpandedParameterPack()) + return true; + } break; case DeclaratorChunk::MemberPointer: diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp index 93c246bdd7..de1c5a708d 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp @@ -68,6 +68,10 @@ void ci(int ... []); // expected-error{{type 'int []' of function parameter pack void di(int ... x[]); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}} } +void f5a(auto fp(int)->unk ...) {} // expected-error{{unknown type name 'unk'}} +void f5b(auto fp(int)->auto ...) {} // expected-error{{'auto' not allowed in function return type}} +void f5c(auto fp()->...) {} // expected-error{{expected a type}} + // FIXME: Expand for function and member pointer types.