diff mbox

[C] remove goto in c_parser_sizeof_expression

Message ID CAJXstsCHg_Sh=G2rOQ5oKz+-dXBzYY_y0n2tad7mRoq6BsujfQ@mail.gmail.com
State New
Headers show

Commit Message

Prathamesh Kulkarni Feb. 22, 2014, 5:04 p.m. UTC
Not sure if this a good idea, but it seemed to me that goto sizeof_expr; wasn't
really required in c_parser_sizeof_expression.
Bootstrapped and regression tested on x8_64-unknown-linux-gnu
Ok for trunk ?

* c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;

Thanks and Regards,
Prathamesh

Comments

Prathamesh Kulkarni Feb. 22, 2014, 5:06 p.m. UTC | #1
On Sat, Feb 22, 2014 at 10:34 PM, Prathamesh Kulkarni
<bilbotheelffriend@gmail.com> wrote:
> Not sure if this a good idea, but it seemed to me that goto sizeof_expr; wasn't
> really required in c_parser_sizeof_expression.
> Bootstrapped and regression tested on x8_64-unknown-linux-gnu
> Ok for trunk ?
>
> * c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;
* c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr.
>
> Thanks and Regards,
> Prathamesh
Marek Polacek Feb. 22, 2014, 6:14 p.m. UTC | #2
On Sat, Feb 22, 2014 at 10:34:13PM +0530, Prathamesh Kulkarni wrote:
> Not sure if this a good idea, but it seemed to me that goto sizeof_expr; wasn't
> really required in c_parser_sizeof_expression.
> Bootstrapped and regression tested on x8_64-unknown-linux-gnu
> Ok for trunk ?
> 
> * c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr;
> 
> Thanks and Regards,
> Prathamesh

I'm not against it, but...

> Index: gcc/c/c-parser.c
> ===================================================================
> --- gcc/c/c-parser.c	(revision 207916)
> +++ gcc/c/c-parser.c	(working copy)
> @@ -6518,26 +6518,27 @@ c_parser_sizeof_expression (c_parser *pa
>  	  expr = c_parser_postfix_expression_after_paren_type (parser,
>  							       type_name,
>  							       expr_loc);
> -	  goto sizeof_expr;
>  	}

Remove { } around expr = c_parser_...

> +      else
> +  {
>        /* sizeof ( type-name ).  */
>        c_inhibit_evaluation_warnings--;
>        in_sizeof--;
>        return c_expr_sizeof_type (expr_loc, type_name);
> +  }

Tab before { and }.

> +    c_inhibit_evaluation_warnings--;
> +    in_sizeof--;
> +    mark_exp_read (expr.value);
> +    if (TREE_CODE (expr.value) == COMPONENT_REF
>  	  && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
>  	error_at (expr_loc, "%<sizeof%> applied to a bit-field");
>        return c_expr_sizeof_expr (expr_loc, expr);

This hunk of code is wrongly indented.

	Marek
diff mbox

Patch

Index: gcc/c/c-parser.c
===================================================================
--- gcc/c/c-parser.c	(revision 207916)
+++ gcc/c/c-parser.c	(working copy)
@@ -6518,26 +6518,27 @@  c_parser_sizeof_expression (c_parser *pa
 	  expr = c_parser_postfix_expression_after_paren_type (parser,
 							       type_name,
 							       expr_loc);
-	  goto sizeof_expr;
 	}
+      else
+  {
       /* sizeof ( type-name ).  */
       c_inhibit_evaluation_warnings--;
       in_sizeof--;
       return c_expr_sizeof_type (expr_loc, type_name);
+  }
     }
   else
     {
       expr_loc = c_parser_peek_token (parser)->location;
       expr = c_parser_unary_expression (parser);
-    sizeof_expr:
-      c_inhibit_evaluation_warnings--;
-      in_sizeof--;
-      mark_exp_read (expr.value);
-      if (TREE_CODE (expr.value) == COMPONENT_REF
+    }
+    c_inhibit_evaluation_warnings--;
+    in_sizeof--;
+    mark_exp_read (expr.value);
+    if (TREE_CODE (expr.value) == COMPONENT_REF
 	  && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1)))
 	error_at (expr_loc, "%<sizeof%> applied to a bit-field");
       return c_expr_sizeof_expr (expr_loc, expr);
-    }
 }
 
 /* Parse an alignof expression.  */