* 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> 2004-01-30 Giovanni Bajo <giovannibajo@gcc.gnu.org>
DR206 DR206

View File

@ -5474,6 +5474,11 @@ cp_parser_statement (cp_parser* parser, bool in_statement_expr_p)
case constant-expression : 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 Returns the new CASE_LABEL, for a `case' or `default' label. For
an ordinary label, returns a LABEL_STMT. */ 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: case RID_CASE:
{ {
tree expr; tree expr, expr_hi;
cp_token *ellipsis;
/* Consume the `case' token. */ /* Consume the `case' token. */
cp_lexer_consume_token (parser->lexer); 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, expr = cp_parser_constant_expression (parser,
/*allow_non_constant_p=*/false, /*allow_non_constant_p=*/false,
NULL); 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) if (!parser->in_switch_statement_p)
error ("case label `%E' not within a switch statement", expr); error ("case label `%E' not within a switch statement", expr);
else else
statement = finish_case_label (expr, NULL_TREE); statement = finish_case_label (expr, expr_hi);
} }
break; break;