On Wed, Jul 27, 2016 at 11:50:56PM +0200, Marek Polacek wrote:
> This testcase was breaking because we were using uninitialized memory
> coming from c_expr in c_parser_switch_statement. There, in case we hadn't
> seen '(' after switch, we called c_finish_case with uninitialized CE.
> Fixed thus.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2016-07-27 Marek Polacek <[email protected]>
>
> PR c/71853
> * c-parser.c (c_parser_switch_statement): Initialize ce.original_type
> to error node for invalid code.
>
> * gcc.dg/noncompile/pr71853.c: New test.
>
> diff --git gcc/c/c-parser.c gcc/c/c-parser.c
> index 8952bca..3679654 100644
> --- gcc/c/c-parser.c
> +++ gcc/c/c-parser.c
> @@ -5661,6 +5661,7 @@ c_parser_switch_statement (c_parser *parser, bool *if_p)
> {
> switch_cond_loc = UNKNOWN_LOCATION;
> expr = error_mark_node;
> + ce.original_type = error_mark_node;
> }
> c_start_case (switch_loc, switch_cond_loc, expr, explicit_cast_p);
> save_break = c_break_label;
> diff --git gcc/testsuite/gcc.dg/noncompile/pr71853.c
> gcc/testsuite/gcc.dg/noncompile/pr71853.c
> index e69de29..e049c8e 100644
> --- gcc/testsuite/gcc.dg/noncompile/pr71853.c
> +++ gcc/testsuite/gcc.dg/noncompile/pr71853.c
> @@ -0,0 +1,9 @@
> +/* PR c/71426 */
Bad PR number. Fixed in my local copy.
Marek