Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit b4e9000

Browse files
committed
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
1 parent 6d32949 commit b4e9000

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

Diff for: lib/Sema/SemaTemplateVariadic.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -782,11 +782,11 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
782782
Chunk.Fun.NoexceptExpr->containsUnexpandedParameterPack())
783783
return true;
784784

785-
if (Chunk.Fun.hasTrailingReturnType() &&
786-
Chunk.Fun.getTrailingReturnType()
787-
.get()
788-
->containsUnexpandedParameterPack())
789-
return true;
785+
if (Chunk.Fun.hasTrailingReturnType()) {
786+
QualType T = Chunk.Fun.getTrailingReturnType().get();
787+
if (!T.isNull() && T->containsUnexpandedParameterPack())
788+
return true;
789+
}
790790
break;
791791

792792
case DeclaratorChunk::MemberPointer:

Diff for: test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ void ci(int ... []); // expected-error{{type 'int []' of function parameter pack
6868
void di(int ... x[]); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}}
6969
}
7070

71+
void f5a(auto fp(int)->unk ...) {} // expected-error{{unknown type name 'unk'}}
72+
void f5b(auto fp(int)->auto ...) {} // expected-error{{'auto' not allowed in function return type}}
73+
void f5c(auto fp()->...) {} // expected-error{{expected a type}}
74+
7175
// FIXME: Expand for function and member pointer types.
7276

7377

0 commit comments

Comments
 (0)