* parser.c (cp_parser_labeled_statement): Accept case ranges.

From-SVN: r76972
This commit is contained in:
Michael Matz 2004-01-30 17:01:29 +00:00 committed by Michael Matz
parent d0acf599c8
commit 98ce043bed
2 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2004-01-30 Michael Matz <matz@suse.de>
* parser.c (cp_parser_labeled_statement): Accept case ranges.
2004-01-30 Giovanni Bajo <giovannibajo@gcc.gnu.org>
DR206

View File

@ -5472,7 +5472,12 @@ cp_parser_statement (cp_parser* parser, bool in_statement_expr_p)
labeled-statement:
identifier : statement
case constant-expression : statement
default : statement
default : statement
GNU Extension:
labeled-statement:
case constant-expression ... constant-expression : statement
Returns the new CASE_LABEL, for a `case' or `default' label. For
an ordinary label, returns a LABEL_STMT. */
@ -5496,7 +5501,8 @@ cp_parser_labeled_statement (cp_parser* parser, bool in_statement_expr_p)
{
case RID_CASE:
{
tree expr;
tree expr, expr_hi;
cp_token *ellipsis;
/* Consume the `case' token. */
cp_lexer_consume_token (parser->lexer);
@ -5504,10 +5510,26 @@ cp_parser_labeled_statement (cp_parser* parser, bool in_statement_expr_p)
expr = cp_parser_constant_expression (parser,
/*allow_non_constant_p=*/false,
NULL);
ellipsis = cp_lexer_peek_token (parser->lexer);
if (ellipsis->type == CPP_ELLIPSIS)
{
/* Consume the `...' token. */
cp_lexer_consume_token (parser->lexer);
expr_hi =
cp_parser_constant_expression (parser,
/*allow_non_constant_p=*/false,
NULL);
/* We don't need to emit warnings here, as the common code
will do this for us. */
}
else
expr_hi = NULL_TREE;
if (!parser->in_switch_statement_p)
error ("case label `%E' not within a switch statement", expr);
else
statement = finish_case_label (expr, NULL_TREE);
statement = finish_case_label (expr, expr_hi);
}
break;