diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2022-05-04 08:34:26 -0400 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2022-05-04 08:35:47 -0400 |
commit | 2cb2cd242ca08d0bbd2a51a41f1317442e5414fc (patch) | |
tree | 8daba516b1e6467fc4eb5207e02bb147650f6de5 /clang/lib/Parse/Parser.cpp | |
parent | b540ee540266f42b238e683c775c32a10c184ab5 (diff) | |
download | llvm-2cb2cd242ca08d0bbd2a51a41f1317442e5414fc.zip llvm-2cb2cd242ca08d0bbd2a51a41f1317442e5414fc.tar.gz llvm-2cb2cd242ca08d0bbd2a51a41f1317442e5414fc.tar.bz2 |
Change the behavior of implicit int diagnostics
C89 allowed a type specifier to be elided with the resulting type being
int, aka implicit int behavior. This feature was subsequently removed
in C99 without a deprecation period, so implementations continued to
support the feature. Now, as with implicit function declarations, is a
good time to reevaluate the need for this support.
This patch allows -Wimplicit-int to issue warnings in C89 mode (off by
default), defaults the warning to an error in C99 through C17, and
disables support for the feature entirely in C2x. It also removes a
warning about missing declaration specifiers that really was just an
implicit int warning in disguise and other minor related cleanups.
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index e72dd93..7ffaf05 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1195,10 +1195,12 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, const DeclaratorChunk::FunctionTypeInfo &FTI = D.getFunctionTypeInfo(); TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth); - // If this is C90 and the declspecs were completely missing, fudge in an + // If this is C89 and the declspecs were completely missing, fudge in an // implicit int. We do this here because this is the only place where // declaration-specifiers are completely optional in the grammar. - if (getLangOpts().ImplicitInt && D.getDeclSpec().isEmpty()) { + if (getLangOpts().isImplicitIntRequired() && D.getDeclSpec().isEmpty()) { + Diag(D.getIdentifierLoc(), diag::warn_missing_type_specifier) + << D.getDeclSpec().getSourceRange(); const char *PrevSpec; unsigned DiagID; const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy(); |