[Bug c++/53863] misleading error message for redefinitions

2021-07-16 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53863

Jonathan Wakely  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-07-16

--- Comment #2 from Jonathan Wakely  ---
Current trunk says this:

53863.C:2:12: error: 'a' conflicts with a previous declaration
2 | enum { a = 1 };
  |^
53863.C:1:8: note: previous declaration ' a'
1 | enum { a = 1 };
  |^

The caret on the error seems wrong, as it points to the initializer not the
enumerator. The note is correct.

[Bug c++/53863] misleading error message for redefinitions

2012-07-05 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53863

Jonathan Wakely redi at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||diagnostic

--- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org 2012-07-05 
10:45:51 UTC ---
In the words of the C++ standard a = 1 is an enumerator-definition, which
declares the name a

(EDG says declaration for C and C++, Clang says definition for C and C++)

I think the reason for the G++ wording is that the same diagnostic is used in
this case:

extern int a;
extern long a;

t.cc:2:13: error: conflicting declaration 'long int a'
t.cc:1:12: error: 'a' has a previous declaration as 'int a'

And in this case they are declarations, not definitions.

Interestingly the C front end gives a different diagnostic here, changing
definition to declaration

t.c:2:13: error: conflicting types for 'a'
t.c:1:12: note: previous declaration of 'a' was here