From: Richard Biener Date: Wed, 11 Jan 2017 11:26:59 +0000 (+0000) Subject: re PR bootstrap/79052 (bootstrap-ubsan failures due to warnings) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e325277522ec7a72286f1faa5bfb47f4b4be3d81;p=gcc.git re PR bootstrap/79052 (bootstrap-ubsan failures due to warnings) 2017-01-11 Richard Biener PR bootstrap/79052 * gimple-parser.c (c_parser_gimple_switch_stmt): Add missing returns on parse errors. From-SVN: r244310 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6e1c9857016..a47e10c06ea 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-01-11 Richard Biener + + PR bootstrap/79052 + * gimple-parser.c (c_parser_gimple_switch_stmt): Add missing + returns on parse errors. + 2017-01-04 Marek Polacek PR c++/64767 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index 291bbf6159e..37e792ac355 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -1259,118 +1259,120 @@ c_parser_gimple_switch_stmt (c_parser *parser, gimple_seq *seq) gimple_seq switch_body = NULL; c_parser_consume_token (parser); - if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) - { - cond_expr = c_parser_gimple_postfix_expression (parser); - if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) - return; - } + if (! c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) + return; + cond_expr = c_parser_gimple_postfix_expression (parser); + if (! c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>")) + return; + + if (! c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>")) + return; - if (c_parser_require (parser, CPP_OPEN_BRACE, "expected %<{%>")) + while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE)) { - while (c_parser_next_token_is_not (parser, CPP_CLOSE_BRACE)) + if (c_parser_next_token_is (parser, CPP_EOF)) { - if (c_parser_next_token_is (parser, CPP_EOF)) - { - c_parser_error (parser, "expected statement"); - return; - } + c_parser_error (parser, "expected statement"); + return; + } - switch (c_parser_peek_token (parser)->keyword) - { - case RID_CASE: - { - c_expr exp1; - location_t loc = c_parser_peek_token (parser)->location; - c_parser_consume_token (parser); + switch (c_parser_peek_token (parser)->keyword) + { + case RID_CASE: + { + c_expr exp1; + location_t loc = c_parser_peek_token (parser)->location; + c_parser_consume_token (parser); - if (c_parser_next_token_is (parser, CPP_NAME) - || c_parser_peek_token (parser)->type == CPP_NUMBER) - exp1 = c_parser_gimple_postfix_expression (parser); - else - c_parser_error (parser, "expected expression"); + if (c_parser_next_token_is (parser, CPP_NAME) + || c_parser_peek_token (parser)->type == CPP_NUMBER) + exp1 = c_parser_gimple_postfix_expression (parser); + else + { + c_parser_error (parser, "expected expression"); + return; + } - if (c_parser_next_token_is (parser, CPP_COLON)) + if (c_parser_next_token_is (parser, CPP_COLON)) + { + c_parser_consume_token (parser); + if (c_parser_next_token_is (parser, CPP_NAME)) { + label = c_parser_peek_token (parser)->value; c_parser_consume_token (parser); - if (c_parser_next_token_is (parser, CPP_NAME)) - { - label = c_parser_peek_token (parser)->value; - c_parser_consume_token (parser); - tree decl = lookup_label_for_goto (loc, label); - case_label = build_case_label (exp1.value, NULL_TREE, - decl); - labels.safe_push (case_label); - if (! c_parser_require (parser, CPP_SEMICOLON, - "expected %<;%>")) - return; - } - else if (! c_parser_require (parser, CPP_NAME, - "expected label")) + tree decl = lookup_label_for_goto (loc, label); + case_label = build_case_label (exp1.value, NULL_TREE, + decl); + labels.safe_push (case_label); + if (! c_parser_require (parser, CPP_SEMICOLON, + "expected %<;%>")) return; } - else if (! c_parser_require (parser, CPP_SEMICOLON, - "expected %<:%>")) + else if (! c_parser_require (parser, CPP_NAME, + "expected label")) return; - break; } - case RID_DEFAULT: + else if (! c_parser_require (parser, CPP_SEMICOLON, + "expected %<:%>")) + return; + break; + } + case RID_DEFAULT: + { + location_t loc = c_parser_peek_token (parser)->location; + c_parser_consume_token (parser); + if (c_parser_next_token_is (parser, CPP_COLON)) { - location_t loc = c_parser_peek_token (parser)->location; c_parser_consume_token (parser); - if (c_parser_next_token_is (parser, CPP_COLON)) + if (c_parser_next_token_is (parser, CPP_NAME)) { + label = c_parser_peek_token (parser)->value; c_parser_consume_token (parser); - if (c_parser_next_token_is (parser, CPP_NAME)) - { - label = c_parser_peek_token (parser)->value; - c_parser_consume_token (parser); - tree decl = lookup_label_for_goto (loc, label); - default_label = build_case_label (NULL_TREE, NULL_TREE, - decl); - if (! c_parser_require (parser, CPP_SEMICOLON, - "expected %<;%>")) - return; - } - else if (! c_parser_require (parser, CPP_NAME, - "expected label")) + tree decl = lookup_label_for_goto (loc, label); + default_label = build_case_label (NULL_TREE, NULL_TREE, + decl); + if (! c_parser_require (parser, CPP_SEMICOLON, + "expected %<;%>")) return; } - else if (! c_parser_require (parser, CPP_SEMICOLON, - "expected %<:%>")) + else if (! c_parser_require (parser, CPP_NAME, + "expected label")) return; - break; } - case RID_GOTO: + else if (! c_parser_require (parser, CPP_SEMICOLON, + "expected %<:%>")) + return; + break; + } + case RID_GOTO: + { + location_t loc = c_parser_peek_token (parser)->location; + c_parser_consume_token (parser); + if (c_parser_next_token_is (parser, CPP_NAME)) { - location_t loc = c_parser_peek_token (parser)->location; + c_parser_gimple_goto_stmt (loc, + c_parser_peek_token + (parser)->value, + &switch_body); c_parser_consume_token (parser); - if (c_parser_next_token_is (parser, CPP_NAME)) + if (c_parser_next_token_is (parser, CPP_SEMICOLON)) + c_parser_consume_token (parser); + else { - c_parser_gimple_goto_stmt (loc, - c_parser_peek_token - (parser)->value, - &switch_body); - c_parser_consume_token (parser); - if (c_parser_next_token_is (parser, CPP_SEMICOLON)) - c_parser_consume_token (parser); - else - { - c_parser_error (parser, "expected semicolon"); - return; - } + c_parser_error (parser, "expected semicolon"); + return; } - else if (! c_parser_require (parser, CPP_NAME, - "expected label")) - return; - break; } - default: - c_parser_error (parser, "expected case label or goto statement"); + else if (! c_parser_require (parser, CPP_NAME, + "expected label")) return; - } - + break; + } + default: + c_parser_error (parser, "expected case label or goto statement"); + return; } + } if (! c_parser_require (parser, CPP_CLOSE_BRACE, "expected %<}%>")) return;