[cfe-commits] r50672 - in /cfe/trunk: Driver/clang.cpp lib/Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Mon May 5 14:18:06 PDT 2008
Author: lattner
Date: Mon May 5 16:18:06 2008
New Revision: 50672
URL: http://llvm.org/viewvc/llvm-project?rev=50672&view=rev
Log:
Add support for -Wimplicit-function-declaration, rdar://5907433
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=50672&r1=50671&r2=50672&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon May 5 16:18:06 2008
@@ -475,6 +475,9 @@
WarnUndefMacros("Wundef",
llvm::cl::desc("Warn on use of undefined macros in #if's"));
+static llvm::cl::opt<bool>
+WarnImplicitFunctionDeclaration("Wimplicit-function-declaration"
+ "Warn about use of implicitly defined functions");
/// InitializeDiagnostics - Initialize the diagnostic object, based on the
/// current command line option settings.
@@ -498,6 +501,10 @@
if (!WarnUndefMacros)
Diags.setDiagnosticMapping(diag::warn_pp_undef_identifier,diag::MAP_IGNORE);
+ if (!WarnImplicitFunctionDeclaration)
+ Diags.setDiagnosticMapping(diag::warn_implicit_function_decl,
+ diag::MAP_IGNORE);
+
if (MSExtensions) // MS allows unnamed struct/union fields.
Diags.setDiagnosticMapping(diag::w_no_declarators, diag::MAP_IGNORE);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=50672&r1=50671&r2=50672&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 5 16:18:06 2008
@@ -1268,9 +1268,10 @@
/// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
IdentifierInfo &II, Scope *S) {
- if (getLangOptions().C99) // Extension in C99.
+ // Extension in C99. Legal in C90, but warn about it.
+ if (getLangOptions().C99)
Diag(Loc, diag::ext_implicit_function_decl, II.getName());
- else // Legal in C90, but warn about it.
+ else
Diag(Loc, diag::warn_implicit_function_decl, II.getName());
// FIXME: handle stuff like:
More information about the cfe-commits
mailing list