diff options
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 6dfd6cd02e9..aa7410afcfd 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3629,10 +3629,6 @@ grokdeclarator (tree declarator, tree declspecs, } } - /* Check the type and width of a bit-field. */ - if (bitfield) - check_bitfield_type_and_width (&type, width, orig_name); - /* Figure out the type qualifiers for the declaration. There are two ways a declaration can become qualified. One is something like `const int i' where the `const' is explicit. Another is @@ -4142,6 +4138,10 @@ grokdeclarator (tree declarator, tree declspecs, /* Now TYPE has the actual type. */ + /* Check the type and width of a bit-field. */ + if (bitfield) + check_bitfield_type_and_width (&type, width, orig_name); + /* Did array size calculations overflow? */ if (TREE_CODE (type) == ARRAY_TYPE @@ -5141,7 +5141,7 @@ finish_struct (tree t, tree fieldlist, tree attributes) make it one, warn and turn off the flag. */ if (TREE_CODE (t) == UNION_TYPE && TYPE_TRANSPARENT_UNION (t) - && TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))) + && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t)))) { TYPE_TRANSPARENT_UNION (t) = 0; warning ("union cannot be made transparent"); @@ -5293,9 +5293,19 @@ finish_enum (tree enumtype, tree values, tree attributes) TYPE_MIN_VALUE (enumtype) = minnode; TYPE_MAX_VALUE (enumtype) = maxnode; - TYPE_PRECISION (enumtype) = precision; TREE_UNSIGNED (enumtype) = unsign; TYPE_SIZE (enumtype) = 0; + + /* If the precision of the type was specific with an attribute and it + was too small, give an error. Otherwise, use it. */ + if (TYPE_PRECISION (enumtype)) + { + if (precision > TYPE_PRECISION (enumtype)) + error ("specified mode too small for enumeral values"); + } + else + TYPE_PRECISION (enumtype) = precision; + layout_type (enumtype); if (values != error_mark_node) |