will wray
2018-09-19 14:41:46 UTC
Re: "Pretty print of enumerator never prints the id,
always falls back to C-style cast output"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87364
The bug report gives a one-line 'fix' to enable output of enum id
but, for C++11 scoped enums, it fails to qualify as enum type::id.
The code is located in c-pretty-print.c
It has not been updated to deal with C++11 scoped enumerations.
'Separation of responsibilities' between c and cxx-pretty-print
seems fairly lax - it's convenient to push some c++ printing to c
(there are a few comments like /* This C++ bit is handled here...*/)
I have not quite managed to make a fix confined to c-pretty-print.c
I have a fix which duplicates the code in pp_c_enumeration_constant
to pp_cxx_enumeration_constant in cxx-pretty print, with modification
if (value != NULL_TREE)
{
if (ENUM_IS_SCOPED (type))
pp_cxx_nested_name_specifier (pp, type);
pp->id_expression (TREE_PURPOSE (value));
}
This works in my testing so far, but
- It duplicates code from c to cxx (not DRY 'Don't Repeat Yourself)
- I didn't find a single function to print full nested, scoped id
so had to check if ENUM_IS_SCOPED to output nested specifiers.
I'm learning by hacking but would like guidance on a proper fix
from anyone more familiar with gcc pretty print and/or grammar -
the guideline comment, at the top of the file, states:
/* The pretty-printer code is primarily designed to closely follow
(GNU) C and C++ grammars... */
I'd appreciate any recommendations towards a proper fix,
or pointers for how to write unit tests for the fix.
Thanks, Will
always falls back to C-style cast output"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87364
The bug report gives a one-line 'fix' to enable output of enum id
but, for C++11 scoped enums, it fails to qualify as enum type::id.
The code is located in c-pretty-print.c
It has not been updated to deal with C++11 scoped enumerations.
'Separation of responsibilities' between c and cxx-pretty-print
seems fairly lax - it's convenient to push some c++ printing to c
(there are a few comments like /* This C++ bit is handled here...*/)
I have not quite managed to make a fix confined to c-pretty-print.c
I have a fix which duplicates the code in pp_c_enumeration_constant
to pp_cxx_enumeration_constant in cxx-pretty print, with modification
if (value != NULL_TREE)
{
if (ENUM_IS_SCOPED (type))
pp_cxx_nested_name_specifier (pp, type);
pp->id_expression (TREE_PURPOSE (value));
}
This works in my testing so far, but
- It duplicates code from c to cxx (not DRY 'Don't Repeat Yourself)
- I didn't find a single function to print full nested, scoped id
so had to check if ENUM_IS_SCOPED to output nested specifiers.
I'm learning by hacking but would like guidance on a proper fix
from anyone more familiar with gcc pretty print and/or grammar -
the guideline comment, at the top of the file, states:
/* The pretty-printer code is primarily designed to closely follow
(GNU) C and C++ grammars... */
I'd appreciate any recommendations towards a proper fix,
or pointers for how to write unit tests for the fix.
Thanks, Will