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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Will Wray from comment #4)
> I reckon that demangling is the cause of the spurious warning.
> It seems that demangle continues to output enums with C-style cast:
> 
>           template type  TreeVector<int, E::a>::Tree
>            demangles as  TreeVector<int, (E)0>::Tree
> 
> Is this demangle angle a red-herring?
> Is the C-style cast mandated by Itanium CXXABI for enum output?

The ABI doesn't mandate how exactly it is demangled, but there is nothing in
the mangled name that would allow it to be demangled as E::a or a.
E.g. with

enum E { a = 0, b = 1 };
template <E e>
const char *foo (void) { return __PRETTY_FUNCTION__; }
void bar (void) { foo <a> (); foo <b> (); }

the mangled names are _Z3fooIL1E0EEPKcv and _Z3fooIL1E1EEPKcv and that is what
the ABI says; there is no way to recover that 0 is a and 1 is b.
__PRETTY_FUNCTION__ is const char* foo() [with E e = a] etc. (previously this
was [with E e = (E)0] ).  Similarly, in .debug_info, DW_AT_name for the
functions used to be foo<(E)0> and now is foo<a>.

> Is demangler code even able to look up enumerators?

No.

> (I mean, does it have access to sufficient type information).

Demangler works just on a string, it doesn't have access to debuginfo etc.

I'd say we should revert to what we used to do when emitting stuff for RTTI or
debug info and do what your patch does only for compiler diagnostics.
Unlike the enumerator ids, the casts with exact constants are much easier to
handle for tools that don't have always full context.

Reply via email to