aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2022-05-04 08:34:26 -0400
committerAaron Ballman <aaron@aaronballman.com>2022-05-04 08:35:47 -0400
commit2cb2cd242ca08d0bbd2a51a41f1317442e5414fc (patch)
tree8daba516b1e6467fc4eb5207e02bb147650f6de5 /clang/lib/Parse/ParseDecl.cpp
parentb540ee540266f42b238e683c775c32a10c184ab5 (diff)
downloadllvm-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/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 2b386c8..3d18ffe 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2637,8 +2637,8 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
// error, do lookahead to try to do better recovery. This never applies
// within a type specifier. Outside of C++, we allow this even if the
// language doesn't "officially" support implicit int -- we support
- // implicit int as an extension in C99 and C11.
- if (!isTypeSpecifier(DSC) && !getLangOpts().CPlusPlus &&
+ // implicit int as an extension in some language modes.
+ if (!isTypeSpecifier(DSC) && getLangOpts().isImplicitIntAllowed() &&
isValidAfterIdentifierInDeclarator(NextToken())) {
// If this token is valid for implicit int, e.g. "static x = 4", then
// we just avoid eating the identifier, so it will be parsed as the