On Tue, 26 Apr 2016, Marek Polacek wrote: > This PR was reopened, because the exact same problem with treating a TYPENAME > wrongly as an ID was found when using just if-clause, without an enclosing for > loop. More details: > <https://gcc.gnu.org/ml/gcc-patches/2015-11/msg01588.html>. > That fix had a follow-up, because it broke some ObjC code. > > To fix this, we need to use the (amended) token reclassification even when > parsing an if statement. I factored the code into a separate function so as > to > not repeat the very same code. > > Bootstrapped/regtested on x86_64-linux, ok for trunk?
I think you need more thorough testcases, to cover the cases where the if statement with no else forms the body of a switch or while statement, and the declaration in question appears in the expression of that switch or while statement, e.g. typedef int T; switch (sizeof (enum { T })) if (1) ; T x; -- Joseph S. Myers jos...@codesourcery.com