]> granicus.if.org Git - clang/commitdiff
[Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.
authorVolodymyr Sapsai <vsapsai@apple.com>
Tue, 2 Jan 2018 18:02:19 +0000 (18:02 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Tue, 2 Jan 2018 18:02:19 +0000 (18:02 +0000)
rdar://problem/33251668

Reviewers: arphaman, ahatanak

Reviewed By: arphaman

Subscribers: ptitei, cfe-commits

Differential Revision: https://reviews.llvm.org/D41528

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321660 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/Sema/warn-strict-prototypes.c

index 4dab52a9f5f44c18257036515b5f21ade5d31170..af060cf21b5fa4a92c8d3a3c6b7c42de62fab6b4 100644 (file)
@@ -4767,7 +4767,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
         break;
       case DeclaratorChunk::Function: {
         const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
-        if (FTI.NumParams == 0)
+        if (FTI.NumParams == 0 && !FTI.isVariadic)
           S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
               << IsBlock
               << FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");
index a28f57d48c84f64023ed88de81e42d53eeffff55..0c23b3b2c2453f7d4e11092645c10fd196976439 100644 (file)
@@ -65,3 +65,9 @@ void foo11(p, p2) int p; int p2; {}
 void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style function definition is not preceded by a prototype}}
   short d;
 {}
+
+// No warnings for variadic functions. Overloadable attribute is required
+// to avoid err_ellipsis_first_param error.
+// rdar://problem/33251668
+void foo13(...) __attribute__((overloadable));
+void foo13(...) __attribute__((overloadable)) {}