r321660 - [Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.

Volodymyr Sapsai via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 10:02:19 PST 2018


Author: vsapsai
Date: Tue Jan  2 10:02:19 2018
New Revision: 321660

URL: http://llvm.org/viewvc/llvm-project?rev=321660&view=rev
Log:
[Sema] Don't emit the -Wstrict-prototypes warning for variadic functions.

rdar://problem/33251668

Reviewers: arphaman, ahatanak

Reviewed By: arphaman

Subscribers: ptitei, cfe-commits

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

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Sema/warn-strict-prototypes.c

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=321660&r1=321659&r2=321660&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jan  2 10:02:19 2018
@@ -4767,7 +4767,7 @@ static TypeSourceInfo *GetFullTypeForDec
         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");

Modified: cfe/trunk/test/Sema/warn-strict-prototypes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-strict-prototypes.c?rev=321660&r1=321659&r2=321660&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-strict-prototypes.c (original)
+++ cfe/trunk/test/Sema/warn-strict-prototypes.c Tue Jan  2 10:02:19 2018
@@ -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)) {}




More information about the cfe-commits mailing list