This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] fix C enum representation

In message <>, Richard Henderson writes:
 >Fixes enum types to have the proper TYPE_MIN/MAX_VALUE for the
 >compatible integer type.  This lets us remove some special case
 >hacks for switch statements.
 >I thought about putting this on mainline as well, but testing
 >revealed that it broke -Wswitch.  Fixing that would require
 >backporting another much larger patch from tree-ssa branch.
 >At which point I gave it up as a bad idea.
 >        * c-tree.h (struct lang_type): Add enum_min, enum_max.
 >        * c-decl.c (finish_enum): Set them.  Set TYPE_MIN/MAX_VALUE to
 >        the limits of the compatible type, not to the enumerators.
 >        (check_bitfield_type_and_width): Use them.
 >        (finish_struct): Clear allocated struct lang_type.
 >        * gimplify.c (gimplify_switch_expr): Remove special handling of
 >        outer cast in a switch.
 >        * tree-ssa-dom.c (record_equivalences_from_incoming_edge): Likewise.
Note you can probably clean up a long standing minor turd in shorten_compare
as well:

      /* 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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]