aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorMark Mitchell <mmitchel@gcc.gnu.org>2003-07-29 01:14:24 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2003-07-29 01:14:24 +0000
commit7b6d72fcfbd0aa2bb05d81afcdcf5e4c6027b2e8 (patch)
treeaa422656fa001e4c76605059943c273de869706a /gcc/c-common.c
parent92a6fb2cf25c126727e85b8d90718ec4cf136cfa (diff)
downloadgcc-7b6d72fcfbd0aa2bb05d81afcdcf5e4c6027b2e8.zip
gcc-7b6d72fcfbd0aa2bb05d81afcdcf5e4c6027b2e8.tar.gz
gcc-7b6d72fcfbd0aa2bb05d81afcdcf5e4c6027b2e8.tar.bz2
re PR c++/11667 (wider-than-int enums never compare equal to 0)
PR c++/11667 * c-common.c (shorten_compare): Take into account differences between C and C++ representation for enumeration types. * tree.h (set_min_and_max_values_for_integral_type): Declare. * stor-layout.c (set_min_and_max_values_for_integral_type): New function, broken out from ... (fixup_signed_type): ... here and ... (fixup_unsigned_type): ... here. PR c++/11667 * call.c (standard_conversion): Allow all integral->enumeral conversions, after marking them as bad. * decl.c (finish_enum): Make sure that all enumerators are properly converted to the underlying type. (build_enumerator): Set DECL_CONTEXT for namespace-scope enumeration types. * pt.c (tsubst_copy): Adjust handling of CONST_DECLs accordingly. (tsubst_enum): Tidy. * Make-lang.in (typeck.o): Depend on convert.h. (class.o): Likewise. (rtti.o): Likewise. * call.c: Include convert.h. (convert_arg_to_ellipsis): Use convert_to_real. * class.c: Include convert.h. (build_base_path): Use convert_to_integer. * rtti.c: Include convert.h. (build_headof): Use convert_to_integer. * typeck.c: Include convert.h. (decay_conversion): Use convert_to_integer. (build_unary_op): Use build_nop. (get_delta_difference): Use convert_to_integer. (build_ptrmemfunc): Avoid unncessary conversions. From-SVN: r69909
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index c579b16..8dea43b 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2214,10 +2214,12 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr,
type = c_common_signed_or_unsigned_type (unsignedp0,
TREE_TYPE (primop0));
- /* If TYPE is an enumeration, then we need to get its min/max
- values from it's underlying integral type, not the enumerated
- type itself. */
- if (TREE_CODE (type) == ENUMERAL_TYPE)
+ /* In C, if TYPE is an enumeration, then we need to get its
+ min/max values from it's underlying integral type, not the
+ enumerated type itself. In C++, TYPE_MAX_VALUE and
+ TYPE_MIN_VALUE have already been set correctly on the
+ enumeration type. */
+ if (!c_dialect_cxx() && TREE_CODE (type) == ENUMERAL_TYPE)
type = c_common_type_for_size (TYPE_PRECISION (type), unsignedp0);
maxval = TYPE_MAX_VALUE (type);