https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121907
Bug ID: 121907 Summary: -Wauto-as-storage-class: New diagnostic Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: foss+...@alejandro-colomar.es Target Milestone: --- Given that auto now means __auto_type, we should diagnose old uses of it as a storage-class specifier. The current hybrid is going to cause confusion in programmers (it already confuses me, FWIW). It seems to be the new 'static', in the sense of being an overloaded keyword. Could we please have this diagnostic and have it in -Wextra (at least)? It should diagnose lines 10 and 13 below. BTW, line 10 should not be an error; those two uses of auto are different and valid, I think. That shows precisely how much this hybrid auto confuses programmers (of compilers). alx@debian:~/tmp/auto$ cat scs.c | nl -ba 1 int typedef i_t; // -Wold-style-declaration 2 3 int 4 main(void) 5 { 6 int static is = 0; // -Wold-style-declaration 7 auto static as = 0; // XXX: Should be -Wold-style-declaration 8 static static ss = 0; // -Wduplicate-decl-specifier (GCC error) 9 int auto ia = 0; // -Wold-style-declaration (Clang error) 10 auto auto aa = 0; // XXX: Why error? Also, would like -Wauto-as-storage-class 11 static auto sa = 0; 12 int int ii = 0; // error 13 auto int ai = 0; // XXX: Would like -Wauto-as-storage-class 14 static int si = 0; 15 } alx@debian:~/tmp/auto$ gcc -Wall -Wextra -std=c23 scs.c -Wno-unused scs.c:1:1: warning: ‘typedef’ is not at beginning of declaration [-Wold-style-declaration] 1 | int typedef i_t; // -Wold-style-declaration | ^~~ scs.c: In function ‘main’: scs.c:6:9: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration] 6 | int static is = 0; // -Wold-style-declaration | ^~~ scs.c:8:9: error: duplicate ‘static’ 8 | static static ss = 0; // -Wduplicate-decl-specifier (GCC error) | ^~~~~~ scs.c:8:25: error: type defaults to ‘int’ in declaration of ‘ss’ [-Wimplicit-int] 8 | static static ss = 0; // -Wduplicate-decl-specifier (GCC error) | ^~ scs.c:9:9: warning: ‘auto’ is not at beginning of declaration [-Wold-style-declaration] 9 | int auto ia = 0; // -Wold-style-declaration (Clang error) | ^~~ scs.c:10:9: error: duplicate ‘auto’ 10 | auto auto aa = 0; // XXX: Why error? Also, would like -Wauto-as-storage-class | ^~~~ scs.c:12:17: error: two or more data types in declaration specifiers 12 | int int ii = 0; // error | ^~~