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

--- Comment #10 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
I'd consider it a bug that the existing -Wparentheses warning for 
ambiguous "else" doesn't warn in this case.  As with the existing warning, 
that warning is only appropriate when there is in fact ambiguity (thus, 
not if there were two more "else" clauses in this example so that every 
"if" had one and there was no ambiguity), though the indentation could 
still be misleading without such ambiguity.  I think the existing warning, 
controlled by the existing option (or any new option that's a subset of 
-Wparentheses and enabled by it), should apply to all cases where the 
syntax for statements permits multiple parses differing in which "if" an 
"else" is associated with, and the rule associating it with the nearest 
has to be applied to select between those alternatives.

(Obviously global state as in the prototype is not a correct part of any 
sensible implementation of such a warning, as you need to keep track of 
arbitrarily many nested states for "if" statements currently being 
parsed.)

Reply via email to