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: [C PATCH] remove goto in c_parser_sizeof_expression


On Mon, Feb 24, 2014 at 11:28 PM, Marek Polacek <polacek@redhat.com> wrote:
> On Mon, Feb 24, 2014 at 11:08:27PM +0530, Prathamesh Kulkarni wrote:
>> I apologize for bothering with stupid mistakes.
>
> No problem, it takes some time to get up to speed.
>
>> +  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 still doesn't seem quite right.  As I said:
>
>> > And this should be
>> >   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);
>> >
>
> That is, no tab before error_at (...), but four spaces.
> (Of course there's no need to retest the patch when making such
> trivial adjustments.)
>
Replaced tab by 4 spaces before error_at.
* c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr.
>         Marek
Index: gcc/c/c-parser.c
===================================================================
--- gcc/c/c-parser.c	(revision 207916)
+++ gcc/c/c-parser.c	(working copy)
@@ -6514,30 +6514,29 @@ c_parser_sizeof_expression (c_parser *pa
 	  return ret;
 	}
       if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
+	expr = c_parser_postfix_expression_after_paren_type (parser,
+							     type_name,
+							     expr_loc);
+      else
 	{
-	  expr = c_parser_postfix_expression_after_paren_type (parser,
-							       type_name,
-							       expr_loc);
-	  goto sizeof_expr;
+	  /* sizeof ( type-name ).  */
+	  c_inhibit_evaluation_warnings--;
+	  in_sizeof--;
+	  return c_expr_sizeof_type (expr_loc, type_name);
 	}
-      /* 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
-	  && 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);
     }
+  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.  */

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