diff options
author | James Y Knight <jyknight@google.com> | 2019-05-06 21:37:59 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2019-05-06 21:37:59 +0000 |
commit | e95a9090164d18f491726f25a38550274644ac93 (patch) | |
tree | 67ed7833094a3438940fd8743db49507a2a0c7cd | |
parent | b91f1c80f6212af9c62b235a4f07dab5067add4b (diff) |
PR41183: Don't emit strict-prototypes warning for an implicit function
declaration.
It should emit _only_ an implicit-function-declaration warning, not
both of them.
Differential Revision: https://reviews.llvm.org/D59711
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360084 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaType.cpp | 5 | ||||
-rw-r--r-- | test/Sema/warn-strict-prototypes.c | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 318c676173..86bf90818c 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -5010,7 +5010,10 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, 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"); diff --git a/test/Sema/warn-strict-prototypes.c b/test/Sema/warn-strict-prototypes.c index 0c23b3b2c2..5565a09060 100644 --- a/test/Sema/warn-strict-prototypes.c +++ b/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 @@ void __attribute__((cdecl)) foo12(d) // expected-warning {{this old-style functi // 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 +} |