This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] remove goto in c_parser_sizeof_expression
- From: Prathamesh Kulkarni <bilbotheelffriend at gmail dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Mon, 24 Feb 2014 23:08:27 +0530
- Subject: Re: [C PATCH] remove goto in c_parser_sizeof_expression
- Authentication-results: sourceware.org; auth=none
- References: <CAJXstsCHg_Sh=G2rOQ5oKz+-dXBzYY_y0n2tad7mRoq6BsujfQ at mail dot gmail dot com> <20140222181444 dot GJ10901 at redhat dot com> <CAJXstsDRb_1Vj7XUtEpfmNkKxAFc0xW7SsFW0oxm7GAm_jX+DQ at mail dot gmail dot com> <20140222194827 dot GK10901 at redhat dot com>
On Sun, Feb 23, 2014 at 1:18 AM, Marek Polacek <polacek@redhat.com> wrote:
> On Sun, Feb 23, 2014 at 12:19:49AM +0530, Prathamesh Kulkarni wrote:
>> Is this fine ?
>
> No, there still are some formatting issues.
>
>> 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);
>> - goto sizeof_expr;
>> - }
>> - /* sizeof ( type-name ). */
>> - c_inhibit_evaluation_warnings--;
>> - in_sizeof--;
>> - return c_expr_sizeof_type (expr_loc, type_name);
>> + expr = c_parser_postfix_expression_after_paren_type (parser,
>> + type_name,
>> + expr_loc);
>
> This should be
> if (c_parser_next_token_is (parser, CPP_OPEN_BRACE))
> expr = c_parser_postfix_expression_after_paren_type (parser,
> type_name,
> expr_loc);
>
>> + else
>> + {
>> + /* sizeof ( type-name ). */
>> + c_inhibit_evaluation_warnings--;
>> + in_sizeof--;
>> + return c_expr_sizeof_type (expr_loc, type_name);
>> + }
>
> Replace 8 spaces in indentation with a tab.
>
>> 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);
>
> Two spaces here, not four.
>
>> + 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);
>
> 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);
>
I hope this is fine.
I apologize for bothering with stupid mistakes.
* 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. */