This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR c/9262


> Why is this fix going in the middle end?  I would have thought it should
> touch nothing outside of the parser, and possibly immediate semantic
> analysis.

We try to expand 'case 3:' outside the switch statement.

int foo(int i)
{
  switch (i)
    case 3:
      return 1,
    case 4:      /* { dg-error "parse error" } */
      return 2;
}

When the parse error is encountered, the switch scope is closed and the 
SWITCH_STMT ends up with an empty SWITCH_BODY. The case label is added to 
the chain of statements anyway but after the switch statement, not inside. 
Therefore we die when trying to expand it.

Note that pushcase is prepared to handle this case:

/* Accumulate one case or default label inside a case or switch statement.
   VALUE is the value of the case (a null pointer, for a default label).
   The function CONVERTER, when applied to arguments T and V,
   converts the value V to the type T.

   If not currently inside a case or switch statement, return 1 and do
   nothing.  The caller will print a language-specific error message.
   If VALUE is a duplicate or overlaps, return 2 and do nothing
   except store the (first) duplicate node in *DUPLICATE.
   If VALUE is out of range, return 3 and do nothing.
  If we are jumping into the scope of a cleanup or var-sized array, return 5.
   Return 0 on success.

   Extended to handle range statements.  */

int
pushcase (value, converter, label, duplicate)

-- 
Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]