Author: jyknight Date: Mon May 6 14:37:59 2019 New Revision: 360084 URL: http://llvm.org/viewvc/llvm-project?rev=360084&view=rev Log: 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 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=360084&r1=360083&r2=360084&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Mon May 6 14:37:59 2019 @@ -5010,7 +5010,10 @@ static TypeSourceInfo *GetFullTypeForDec 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"); 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=360084&r1=360083&r2=360084&view=diff ============================================================================== --- cfe/trunk/test/Sema/warn-strict-prototypes.c (original) +++ cfe/trunk/test/Sema/warn-strict-prototypes.c Mon May 6 14:37:59 2019 @@ -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) // // 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 +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits