commit 57bc5e0446e9a26a40168c6c1a651e48277e1ff9
Author: Jason Merrill <jason@redhat.com>
Date: Tue Oct 26 14:49:56 2010 -0400
c-family/
* c-common.c (check_case_value): Remove special C++ code.
cp/
* decl.c (finish_case_label): Use decl_constant_value.
@@ -2588,22 +2588,6 @@ check_case_value (tree value)
if (value == NULL_TREE)
return value;
- /* ??? Can we ever get nops here for a valid case value? We
- shouldn't for C. */
- STRIP_TYPE_NOPS (value);
- /* In C++, the following is allowed:
-
- const int i = 3;
- switch (...) { case i: ... }
-
- So, we try to reduce the VALUE to a constant that way. */
- if (c_dialect_cxx ())
- {
- value = decl_constant_value (value);
- STRIP_TYPE_NOPS (value);
- value = fold (value);
- }
-
if (TREE_CODE (value) == INTEGER_CST)
/* Promote char or short to int. */
value = perform_integral_promotions (value);
@@ -2938,6 +2938,11 @@ finish_case_label (location_t loc, tree low_value, tree high_value)
if (!check_switch_goto (switch_stack->level))
return error_mark_node;
+ if (low_value)
+ low_value = decl_constant_value (low_value);
+ if (high_value)
+ high_value = decl_constant_value (high_value);
+
r = c_add_case_label (loc, switch_stack->cases, cond,
SWITCH_STMT_TYPE (switch_stack->switch_stmt),
low_value, high_value);