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

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 10:03:33 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL321660: [Sema] Don't emit the -Wstrict-prototypes warning for variadic functions. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41528?vs=127965&id=128430#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41528

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


Index: cfe/trunk/lib/Sema/SemaType.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -4767,7 +4767,7 @@
         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: cfe/trunk/test/Sema/warn-strict-prototypes.c
===================================================================
--- cfe/trunk/test/Sema/warn-strict-prototypes.c
+++ cfe/trunk/test/Sema/warn-strict-prototypes.c
@@ -65,3 +65,9 @@
 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)) {}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41528.128430.patch
Type: text/x-patch
Size: 1203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180102/1a1a0679/attachment.bin>


More information about the cfe-commits mailing list