aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Brandon <anthony.brandon@gmail.com>2014-10-13 21:00:55 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2014-10-13 21:00:55 +0000
commit74d98c1e9beaa02e00241d846d9053843acadbe1 (patch)
treebcdb10fc0f8256b0b399de36c10ee5a93e526f44
parent3dce09649d93c3465754c0b027574823607964ab (diff)
downloadgcc-74d98c1e9beaa02e00241d846d9053843acadbe1.zip
gcc-74d98c1e9beaa02e00241d846d9053843acadbe1.tar.gz
gcc-74d98c1e9beaa02e00241d846d9053843acadbe1.tar.bz2
c-parser.c (c_parser_all_labels): New function to replace the duplicate code.
gcc/c/ChangeLog: 2014-10-13 Anthony Brandon <anthony.brandon@gmail.com> * c-parser.c (c_parser_all_labels): New function to replace the duplicate code. (c_parser_statement): Call the new function. From-SVN: r216165
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c30
2 files changed, 21 insertions, 15 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 91ed9d2..b4cc40a 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-13 Anthony Brandon <anthony.brandon@gmail.com>
+
+ * c-parser.c (c_parser_all_labels): New function to replace
+ the duplicate code.
+ (c_parser_statement): Call the new function.
+
2014-10-09 Marek Polacek <polacek@redhat.com>
PR c/63480
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 0d159fd..346448a 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -4654,6 +4654,18 @@ c_parser_compound_statement_nostart (c_parser *parser)
mark_valid_location_for_stdc_pragma (save_valid_for_pragma);
}
+/* Parse all consecutive labels. */
+
+static void
+c_parser_all_labels (c_parser *parser)
+{
+ while (c_parser_next_token_is_keyword (parser, RID_CASE)
+ || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
+ || (c_parser_next_token_is (parser, CPP_NAME)
+ && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
+ c_parser_label (parser);
+}
+
/* Parse a label (C90 6.6.1, C99 6.8.1).
label:
@@ -4854,11 +4866,7 @@ c_parser_label (c_parser *parser)
static void
c_parser_statement (c_parser *parser)
{
- while (c_parser_next_token_is_keyword (parser, RID_CASE)
- || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
- || (c_parser_next_token_is (parser, CPP_NAME)
- && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
- c_parser_label (parser);
+ c_parser_all_labels (parser);
c_parser_statement_after_labels (parser);
}
@@ -5090,11 +5098,7 @@ c_parser_if_body (c_parser *parser, bool *if_p)
{
tree block = c_begin_compound_stmt (flag_isoc99);
location_t body_loc = c_parser_peek_token (parser)->location;
- while (c_parser_next_token_is_keyword (parser, RID_CASE)
- || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
- || (c_parser_next_token_is (parser, CPP_NAME)
- && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
- c_parser_label (parser);
+ c_parser_all_labels (parser);
*if_p = c_parser_next_token_is_keyword (parser, RID_IF);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
@@ -5121,11 +5125,7 @@ c_parser_else_body (c_parser *parser)
{
location_t else_loc = c_parser_peek_token (parser)->location;
tree block = c_begin_compound_stmt (flag_isoc99);
- while (c_parser_next_token_is_keyword (parser, RID_CASE)
- || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
- || (c_parser_next_token_is (parser, CPP_NAME)
- && c_parser_peek_2nd_token (parser)->type == CPP_COLON))
- c_parser_label (parser);
+ c_parser_all_labels (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
location_t loc = c_parser_peek_token (parser)->location;