[PATCH] D59711: PR41183: Don't emit Wstrict-prototypes warning for an implicit function declaration.
James Y Knight via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 14:35:47 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360084: PR41183: Don't emit strict-prototypes warning for an implicit function (authored by jyknight, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D59711?vs=191924&id=198341#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59711/new/
https://reviews.llvm.org/D59711
Files:
lib/Sema/SemaType.cpp
test/Sema/warn-strict-prototypes.c
Index: test/Sema/warn-strict-prototypes.c
===================================================================
--- test/Sema/warn-strict-prototypes.c
+++ test/Sema/warn-strict-prototypes.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -verify %s
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -Wno-implicit-function-declaration -verify %s
// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -Wstrict-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// function declaration with unspecified params
@@ -71,3 +71,9 @@
// rdar://problem/33251668
void foo13(...) __attribute__((overloadable));
void foo13(...) __attribute__((overloadable)) {}
+
+// We should not generate a strict-prototype warning for an implicit
+// declaration. Leave that up to the implicit-function-declaration warning.
+void foo14(void) {
+ foo14_call(); // no-warning
+}
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -5010,7 +5010,10 @@
break;
case DeclaratorChunk::Function: {
const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
- if (FTI.NumParams == 0 && !FTI.isVariadic)
+ // We supress the warning when there's no LParen location, as this
+ // indicates the declaration was an implicit declaration, which gets
+ // warned about separately via -Wimplicit-function-declaration.
+ if (FTI.NumParams == 0 && !FTI.isVariadic && FTI.getLParenLoc().isValid())
S.Diag(DeclType.Loc, diag::warn_strict_prototypes)
<< IsBlock
<< FixItHint::CreateInsertion(FTI.getRParenLoc(), "void");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59711.198341.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190506/b61fd28a/attachment.bin>
More information about the cfe-commits
mailing list