From 10861e9a234fde12c33432d7744940526560a5e9 Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 26 Apr 1995 17:24:01 -0400 Subject: [PATCH] (finish_struct): Add ATTRIBUTES argument, call decl_attributes and set DECL_PACKED from TYPE_PACKED. (finish_struct): Add ATTRIBUTES argument, call decl_attributes and set DECL_PACKED from TYPE_PACKED. (finish_enum): Add ATTRIBUTES argument, call decl_attributes, and make enum narrow if TYPE_PACKED. From-SVN: r9486 --- gcc/c-decl.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 6745ac74ccb..06dff74c57c 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5383,12 +5383,15 @@ field_decl_cmp (x, y) /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T. FIELDLIST is a chain of FIELD_DECL nodes for the fields. + ATTRIBUTES are attributes to be applied to the structure. We also do a pop_obstacks to match the push in start_struct. */ tree -finish_struct (t, fieldlist) - register tree t, fieldlist; +finish_struct (t, fieldlist, attributes) + tree t; + tree fieldlist; + tree attributes; { register tree x; int old_momentary; @@ -5399,6 +5402,8 @@ finish_struct (t, fieldlist) TYPE_SIZE (t) = 0; + decl_attributes (t, attributes, NULL_TREE); + /* Nameless union parm types are useful as GCC extension. */ if (! (TREE_CODE (t) == UNION_TYPE && TYPE_NAME (t) == 0) && !pedantic) /* Otherwise, warn about any struct or union def. in parmlist. */ @@ -5428,6 +5433,7 @@ finish_struct (t, fieldlist) for (x = fieldlist; x; x = TREE_CHAIN (x)) { DECL_CONTEXT (x) = t; + DECL_PACKED (x) = TYPE_PACKED (t); DECL_FIELD_SIZE (x) = 0; /* If any field is const, the structure type is pseudo-const. */ @@ -5763,12 +5769,15 @@ start_enum (name) /* After processing and defining all the values of an enumeration type, install their decls in the enumeration type and finish it off. - ENUMTYPE is the type object and VALUES a list of decl-value pairs. + ENUMTYPE is the type object, VALUES a list of decl-value pairs, + and ATTRIBUTES are the specified attributes. Returns ENUMTYPE. */ tree -finish_enum (enumtype, values) - register tree enumtype, values; +finish_enum (enumtype, values, attributes) + tree enumtype; + tree values; + tree attributes; { register tree pair, tem; tree minnode = 0, maxnode = 0; @@ -5778,6 +5787,8 @@ finish_enum (enumtype, values) if (in_parm_level_p ()) warning ("enum defined inside parms"); + decl_attributes (enumtype, attributes, NULL_TREE); + /* Calculate the maximum value of any enumerator in this type. */ if (values == error_mark_node) @@ -5809,7 +5820,8 @@ finish_enum (enumtype, values) highprec = min_precision (maxnode, TREE_UNSIGNED (enumtype)); precision = MAX (lowprec, highprec); - if (flag_short_enums || precision > TYPE_PRECISION (integer_type_node)) + if (flag_short_enums || TYPE_PACKED (enumtype) + || precision > TYPE_PRECISION (integer_type_node)) /* Use the width of the narrowest normal C type which is wide enough. */ TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size (precision, 1)); else -- 2.30.2