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

            Bug ID: 88520
           Summary: improve warning when `struct` is required
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org
  Target Milestone: ---

Consider this source:

int Foo;

struct Foo
{
  int a;
};

extern int f(Foo x);


gcc (I'm using 8.2.1 from Fedora 28) says:

q.cc:8:14: warning: ‘f’ initialized and declared ‘extern’
 extern int f(Foo x);
              ^~~
q.cc:8:17: error: expected ‘)’ before ‘x’
 extern int f(Foo x);
             ~   ^~
                 )


clang is somewhat nicer here, showing where the definition appeared.
This is handy info for figuring out what went wrong:

q.cc:8:14: error: must use 'struct' tag to refer to type 'Foo' in this scope
extern int f(Foo x);
             ^
             struct 
q.cc:1:5: note: struct 'Foo' is hidden by a non-type declaration of 'Foo' here
int Foo;
    ^


This came up on the gdb list, where a user couldn't figure out why
gcc was erroring.

Reply via email to