Skip to content

[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

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions clang/test/C/C2x/n3007.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions clang/test/Sema/c2x-auto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down