]> granicus.if.org Git - clang/commitdiff
Don't crash on an invalid trailing return type on a function before a '...'
authorNico Weber <nicolasweber@gmx.de>
Tue, 30 Dec 2014 02:06:40 +0000 (02:06 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 30 Dec 2014 02:06:40 +0000 (02:06 +0000)
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

lib/Sema/SemaTemplateVariadic.cpp
test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp

index f5883e429dba84277006aa0fb67bfebb6dd4354f..e4fab71d995be07110ca71d3c7becfd36cd47f14 100644 (file)
@@ -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:
index 93c246bdd7957d098875cde8626f27c8f53bb94c..de1c5a708db687d9a6913be57ca05063c18ee4d7 100644 (file)
@@ -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.