On 11/05/15 16:21, Marek Polacek wrote:
The -Wshift-negative-value patch caused grief since it breaks building
some programs.  The following patch should alleviate the pain a bit: mark
a left shift of a negative value as non-const only if pedantic.

Either this is not correct according to the guidelines ("the flag pedantic should not cause generated code differences or errors", https://gcc.gnu.org/wiki/DiagnosticsGuidelines) or the guidelines need updating.

My take is that this should work exactly like OPT_Woverflow (see constant_expression_warning):

!flag_isoc99 || !constant_required should produce a warning() with OPT_Wshift_negative_value

flag_isoc99 && constant_required should produce a pedwarn() using (pedantic ? OPT_Wpedantic : OPT_Wshift_negative_value).

The above means that we only produce errors with -std=c99|gnu99 -pedantic-errors in the places that are mandated by the standard. Otherwise, there are no code or error differences and at most there are warnings that are controlled by -Wshift-negative-value for those that want to disable them.

Of course, the problem here is that we are folding this even before we know if a constant is actually required by the standard, no? Is there no way to move the warning to the point where we actually know whether a constant is required or not?

Cheers,

Manuel.

Reply via email to