This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/19874] ICE in emit_move_insn with __attribute__((mode (QI))) enum
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Feb 2005 14:29:02 -0000
- Subject: [Bug middle-end/19874] ICE in emit_move_insn with __attribute__((mode (QI))) enum
- References: <20050210122437.19874.jakub@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jakub at gcc dot gnu dot org 2005-02-21 14:28 -------
This is a regression from GCC 3.4.x and earlier btw.
The problem seems to be that STRIP_USELESS_TYPE_CONVERSION strips
E to E __attribute__ ((mode (__byte__))) conversion as useless, although
it has different TYPE_MODE and TYPE_PRECISION.
This is because both have the same TYPE_MAIN_VARIANT.
I tried following patch which cures this for C, but unfortunately breaks
C++ at the same time (C++ needs both enums to have the same main variant):
--- gcc/c-common.c.jj 2005-02-14 09:25:46.000000000 +0100
+++ gcc/c-common.c 2005-02-21 14:43:53.000000000 +0100
@@ -4364,7 +4364,7 @@ handle_mode_attribute (tree *node, tree
}
if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
- type = build_variant_type_copy (type);
+ type = build_distinct_type_copy (type);
/* We cannot use layout_type here, because that will attempt
to re-layout all variants, corrupting our original. */
--- gcc/c-typeck.c.jj 2005-02-19 00:31:52.000000000 +0100
+++ gcc/c-typeck.c 2005-02-21 15:07:51.249019189 +0100
@@ -755,12 +755,19 @@ comptypes (tree type1, tree type2)
if (c_dialect_objc () && objc_comptypes (t1, t2, 0) == 1)
val = 1;
- case ENUMERAL_TYPE:
case UNION_TYPE:
if (val != 1 && !same_translation_unit_p (t1, t2))
val = tagged_types_tu_compatible_p (t1, t2);
break;
+ /* Don't consider enum E { A, B } and enum E __attribute__((mode (byte)))
+ to be compatible. */
+ case ENUMERAL_TYPE:
+ if (val != 1 && TYPE_MODE (t1) == TYPE_MODE (t2)
+ && !same_translation_unit_p (t1, t2))
+ val = tagged_types_tu_compatible_p (t1, t2);
+ break;
+
case VECTOR_TYPE:
val = TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
&& comptypes (TREE_TYPE (t1), TREE_TYPE (t2));
Alternative would be e.g. to change c_types_compatible_p to special case
ENUMERAL_TYPEs and requiring there TYPE_MODE () to be compatible.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |rth at gcc dot gnu dot org
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19874