On 04/27/2017 01:29 AM, Volker Reichelt wrote:
Hi,

the following two patches aim at improving GCC's diagnostics to help
the user to get rid of old-style casts. While old-style pointer casts
are really bad and need to be weeded out quickly, old-style casts between
arithmetic types are IMHO much more tolerable. The patches allow to
easily distinguish between those situations.

FWIW, it can be most helpful to include this sort of detail (and
similar) in diagnostics.  In the case of the C-style cast, besides
mentioning the type of the result, it might be even more helpful
to mention the type of the operand because unlike that of the
result, its type is not apparent from the cast itself.


The first patch for cp_parser_cast_expression in parser.c just adds
the target type of the cast to the diagnostic (like in
maybe_warn_about_useless_cast in typeck.c).

The second patch for type_to_string in error.c tackles the problem
that the name of a type doesn't tell you if you have a class or just
a simple enum. Similar to adding "{aka 'int'}" to types that
are essentially integers, this patch adds "{enum}" to all
enumeration types (and adjusts two testcases accordingly).

In the C front end %qT prints 'enum E' for an argument of
an enumerated type.  Is there some significance to having
the C++ front end print 'E { enum }' or can C++ be made
consistent?

Martin

Reply via email to