diff options
Diffstat (limited to 'contrib/gcc/c-decl.c')
-rw-r--r-- | contrib/gcc/c-decl.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/contrib/gcc/c-decl.c b/contrib/gcc/c-decl.c index 6e87a76..619b221 100644 --- a/contrib/gcc/c-decl.c +++ b/contrib/gcc/c-decl.c @@ -3620,10 +3620,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 @@ -3983,7 +3979,17 @@ grokdeclarator (tree declarator, tree declspecs, } else if (TREE_CODE (declarator) == CALL_EXPR) { + /* Say it's a definition only for the declarator closest to + the identifier, apart possibly from some attributes. */ + bool really_funcdef = false; tree arg_types; + if (funcdef_flag) + { + tree t = TREE_OPERAND (declarator, 0); + while (TREE_CODE (t) == TREE_LIST) + t = TREE_VALUE (t); + really_funcdef = (TREE_CODE (t) == IDENTIFIER_NODE); + } /* Declaring a function type. Make sure we have a valid type for the function to return. */ @@ -4009,11 +4015,7 @@ grokdeclarator (tree declarator, tree declspecs, inner layer of declarator. */ arg_types = grokparms (TREE_OPERAND (declarator, 1), - funcdef_flag - /* Say it's a definition - only for the CALL_EXPR - closest to the identifier. */ - && TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE); + really_funcdef); /* Type qualifiers before the return type of the function qualify the return type, not the function type. */ if (type_quals) @@ -4127,6 +4129,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 @@ -5126,7 +5132,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"); @@ -5278,9 +5284,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) |