Commit 81f0bab2 by Jason Merrill

c-common.c (check_case_value): Remove special C++ code.

c-family/
	* c-common.c (check_case_value): Remove special C++ code.
cp/
	* decl.c (finish_case_label): Use decl_constant_value.

From-SVN: r166019
parent 5ac13b8e
2010-10-27 Jason Merrill <jason@redhat.com>
* c-common.c (check_case_value): Remove special C++ code.
2010-10-27 Nicola Pero <nicola.pero@meta-innovation.com> 2010-10-27 Nicola Pero <nicola.pero@meta-innovation.com>
* c-common.h (enum rid): Added RID_READWRITE, RID_ASSIGN, * c-common.h (enum rid): Added RID_READWRITE, RID_ASSIGN,
......
...@@ -2588,22 +2588,6 @@ check_case_value (tree value) ...@@ -2588,22 +2588,6 @@ check_case_value (tree value)
if (value == NULL_TREE) if (value == NULL_TREE)
return value; 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) if (TREE_CODE (value) == INTEGER_CST)
/* Promote char or short to int. */ /* Promote char or short to int. */
value = perform_integral_promotions (value); value = perform_integral_promotions (value);
......
2010-10-27 Gabriel Dos Reis <gdr@cse.tamu.edu> 2010-10-27 Gabriel Dos Reis <gdr@cse.tamu.edu>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
* decl.c (finish_case_label): Use decl_constant_value.
* method.c (synthesized_method_walk): Track constexprness too. * method.c (synthesized_method_walk): Track constexprness too.
(process_subob_fn, walk_field_subobs): Likewise. (process_subob_fn, walk_field_subobs): Likewise.
(implicitly_declare_fn): Set DECL_DECLARED_CONSTEXPR_P. (implicitly_declare_fn): Set DECL_DECLARED_CONSTEXPR_P.
......
...@@ -2938,6 +2938,11 @@ finish_case_label (location_t loc, tree low_value, tree high_value) ...@@ -2938,6 +2938,11 @@ finish_case_label (location_t loc, tree low_value, tree high_value)
if (!check_switch_goto (switch_stack->level)) if (!check_switch_goto (switch_stack->level))
return error_mark_node; 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, r = c_add_case_label (loc, switch_stack->cases, cond,
SWITCH_STMT_TYPE (switch_stack->switch_stmt), SWITCH_STMT_TYPE (switch_stack->switch_stmt),
low_value, high_value); low_value, high_value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment