[Bug c/105939] "warning: anonymous struct declared inside parameter list will not be visible outside of this definition or declaration" should have a warning flag attached to it

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 13 01:06:16 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105939

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Oh, one more; I updated the testcase so it's now:

$ cat icculus_twitter_thread.c
#include <stdio.h>

int main(void) {
    int x = 0;
    do printf("%d\n", x++); while (x < 10);
    return 0;
}

const const const static const inline int xx;

xxx();

int xxxx(struct { int a; int b; } x) {
    for (struct { int a; int b; } ; ; ) {
        printf("this doesn't have a warning flag either, fwiw\n");
    }
    return (x.a + x.b);
}
$ /usr/local/bin/gcc -c -Wall -Wextra -Wshadow -pedantic -Wconversion
-Wold-style-definition -Wold-style-declaration -Wduplicated-branches
-Wduplicated-cond -Wlogical-op -Wnull-dereference -Wc++-compat -Wnested-externs
-Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes
-fplan9-extensions icculus_twitter_thread.c
icculus_twitter_thread.c:9:7: warning: duplicate 'const' declaration specifier
[-Wduplicate-decl-specifier]
    9 | const const const static const inline int xx;
      |       ^~~~~
icculus_twitter_thread.c:9:13: warning: duplicate 'const' declaration specifier
[-Wduplicate-decl-specifier]
    9 | const const const static const inline int xx;
      |             ^~~~~
icculus_twitter_thread.c:9:1: warning: 'static' is not at beginning of
declaration [-Wold-style-declaration]
    9 | const const const static const inline int xx;
      | ^~~~~
icculus_twitter_thread.c:9:26: warning: duplicate 'const' declaration specifier
[-Wduplicate-decl-specifier]
    9 | const const const static const inline int xx;
      |                          ^~~~~
icculus_twitter_thread.c:9:1: warning: 'inline' is not at beginning of
declaration [-Wold-style-declaration]
    9 | const const const static const inline int xx;
      | ^~~~~
icculus_twitter_thread.c:9:43: warning: variable 'xx' declared 'inline'
    9 | const const const static const inline int xx;
      |                                           ^~
icculus_twitter_thread.c:9:43: warning: uninitialized 'const xx' is invalid in
C++ [-Wc++-compat]
icculus_twitter_thread.c:11:1: warning: data definition has no type or storage
class
   11 | xxx();
      | ^~~
icculus_twitter_thread.c:11:1: warning: type defaults to 'int' in declaration
of 'xxx' [-Wimplicit-int]
icculus_twitter_thread.c:11:1: warning: function declaration isn't a prototype
[-Wstrict-prototypes]
icculus_twitter_thread.c:13:10: warning: anonymous struct declared inside
parameter list will not be visible outside of this definition or declaration
   13 | int xxxx(struct { int a; int b; } x) {
      |          ^~~~~~
icculus_twitter_thread.c:13:5: warning: no previous prototype for 'xxxx'
[-Wmissing-prototypes]
   13 | int xxxx(struct { int a; int b; } x) {
      |     ^~~~
icculus_twitter_thread.c: In function 'xxxx':
icculus_twitter_thread.c:14:17: warning: unnamed struct/union that defines no
instances
   14 |     for (struct { int a; int b; } ; ; ) {
      |                 ^
icculus_twitter_thread.c: At top level:
icculus_twitter_thread.c:9:43: warning: 'xx' defined but not used
[-Wunused-const-variable=]
    9 | const const const static const inline int xx;
      |                                           ^~
$

(the new warning without the flag attached to it is the one with the "unnamed
struct/union that defines no instances" text)


More information about the Gcc-bugs mailing list