-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang][C2x] Remove confusing diagnostic auto storage class specifier #68710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][C2x] Remove confusing diagnostic auto storage class specifier #68710
Conversation
@llvm/pr-subscribers-clang Author: Guillot Tony (to268) ChangesWhen declaring Full diff: https://github.com/llvm/llvm-project/pull/68710.diff 3 Files Affected:
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index bcc70c04dec91ba..14a28e5a31c57db 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4042,7 +4042,7 @@ void Parser::ParseDeclarationSpecifiers(
if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_auto, Loc,
PrevSpec, DiagID, Policy);
- if (!isInvalid)
+ if (!isInvalid && !getLangOpts().C23)
Diag(Tok, diag::ext_auto_storage_class)
<< FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
} else
diff --git a/clang/test/C/C2x/n3007.c b/clang/test/C/C2x/n3007.c
index 1fd20332ceb4715..34ec419b71b271d 100644
--- a/clang/test/C/C2x/n3007.c
+++ b/clang/test/C/C2x/n3007.c
@@ -3,6 +3,10 @@
/* WG14 N3007: Yes
* Type Inference for object definitions
*/
+void test_auto_int(void) {
+ auto int auto_int = 12;
+}
+
void test_qualifiers(int x, const int y, int * restrict z) {
const auto a = x;
auto b = y;
diff --git a/clang/test/Sema/c2x-auto.c b/clang/test/Sema/c2x-auto.c
index 916c179adcf3182..7cbd1db31315aef 100644
--- a/clang/test/Sema/c2x-auto.c
+++ b/clang/test/Sema/c2x-auto.c
@@ -4,6 +4,7 @@ void test_basic_types(void) {
auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
auto auto_int = 4;
auto auto_long = 4UL;
+ auto int auto_int_ts = 12;
signed auto a = 1L; // expected-error {{'auto' cannot be signed or unsigned}}
_Static_assert(_Generic(auto_int, int : 1));
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick patch!
Can you land this patch on my behalf? |
You should just be able to click "squash and merge", no? |
Nope, I can't
|
When declaring
auto int
at local or file scope, we emit a warning intended for C++11 and later, which is incorrect and confusing in C23.See Godbolt example.
Now this diagnostic does not show up in C23.