diff options
Diffstat (limited to 'contrib/gcc/c-decl.c')
-rw-r--r-- | contrib/gcc/c-decl.c | 103 |
1 files changed, 15 insertions, 88 deletions
diff --git a/contrib/gcc/c-decl.c b/contrib/gcc/c-decl.c index 5cb5270..801a734 100644 --- a/contrib/gcc/c-decl.c +++ b/contrib/gcc/c-decl.c @@ -19,6 +19,8 @@ along with GCC; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + /* Process declarations and symbol lookup for C front end. Also constructs types; the standard scalar types at initialization, and structure, union, array and enum types when they are declared. */ @@ -285,7 +287,6 @@ static tree c_make_fname_decl PARAMS ((tree, int)); static void c_expand_body PARAMS ((tree, int, int)); static void warn_if_shadowing PARAMS ((tree, tree)); static bool flexible_array_type_p PARAMS ((tree)); -static int field_decl_cmp PARAMS ((const PTR, const PTR)); static tree set_save_expr_context PARAMS ((tree *, int *, void *)); /* States indicating how grokdeclarator() should handle declspecs marked @@ -2012,10 +2013,8 @@ pushdecl (x) while (TREE_CODE (element) == ARRAY_TYPE) element = TREE_TYPE (element); - if ((TREE_CODE (element) == RECORD_TYPE - || TREE_CODE (element) == UNION_TYPE) - && (TREE_CODE (x) != TYPE_DECL - || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE)) + if (TREE_CODE (element) == RECORD_TYPE + || TREE_CODE (element) == UNION_TYPE) b->incomplete_list = tree_cons (NULL_TREE, x, b->incomplete_list); } } @@ -5117,28 +5116,6 @@ grokfield (filename, line, declarator, declspecs, width) return value; } -/* Function to help qsort sort FIELD_DECLs by name order. */ - - -static int -field_decl_cmp (xp, yp) - const PTR xp; - const PTR yp; -{ - tree *x = (tree *)xp, *y = (tree *)yp; - - if (DECL_NAME (*x) == DECL_NAME (*y)) - return 0; - if (DECL_NAME (*x) == NULL) - return -1; - if (DECL_NAME (*y) == NULL) - return 1; - if (DECL_NAME (*x) < DECL_NAME (*y)) - return -1; - return 1; -} - - /* 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. */ @@ -5383,53 +5360,6 @@ finish_struct (t, fieldlist, attributes) TYPE_FIELDS (t) = fieldlist; - /* If there are lots of fields, sort so we can look through them fast. - We arbitrarily consider 16 or more elts to be "a lot". */ - - { - int len = 0; - - for (x = fieldlist; x; x = TREE_CHAIN (x)) - { - if (len > 15 || DECL_NAME (x) == NULL) - break; - len += 1; - } - - if (len > 15) - { - tree *field_array; - char *space; - - len += list_length (x); - - /* Use the same allocation policy here that make_node uses, to - ensure that this lives as long as the rest of the struct decl. - All decls in an inline function need to be saved. */ - - space = ggc_alloc (sizeof (struct lang_type) + len * sizeof (tree)); - - len = 0; - field_array = &(((struct lang_type *) space)->elts[0]); - for (x = fieldlist; x; x = TREE_CHAIN (x)) - { - field_array[len++] = x; - - /* if there is anonymous struct or unoin break out of the loop */ - if (DECL_NAME (x) == NULL) - break; - } - /* found no anonymous struct/union add the TYPE_LANG_SPECIFIC. */ - if (x == NULL) - { - TYPE_LANG_SPECIFIC (t) = (struct lang_type *) space; - TYPE_LANG_SPECIFIC (t)->len = len; - field_array = &TYPE_LANG_SPECIFIC (t)->elts[0]; - qsort (field_array, len, sizeof (tree), field_decl_cmp); - } - } - } - for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x)) { TYPE_FIELDS (x) = TYPE_FIELDS (t); @@ -5463,8 +5393,7 @@ finish_struct (t, fieldlist, attributes) && TREE_CODE (decl) != TYPE_DECL) { layout_decl (decl, 0); - /* This is a no-op in c-lang.c or something real in - objc-act.c. */ + /* This is a no-op in c-lang.c or something real in objc-act.c. */ if (flag_objc) objc_check_decl (decl); rest_of_decl_compilation (decl, NULL, toplevel, 0); @@ -5500,11 +5429,7 @@ finish_struct (t, fieldlist, attributes) else current_binding_level->incomplete_list = TREE_CHAIN (x); } - else - prev = x; } - else - prev = x; } } @@ -5876,7 +5801,9 @@ start_function (declspecs, declarator, attributes) && !(old_decl != 0 && (TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0 || (DECL_BUILT_IN (old_decl) - && ! C_DECL_ANTICIPATED (old_decl))))) + && ! C_DECL_ANTICIPATED (old_decl)))) + && !(flag_bsd_no_warn_kr_main && 0 == + strcmp ("main", IDENTIFIER_POINTER (DECL_NAME (decl1))))) warning ("function declaration isn't a prototype"); /* Optionally warn of any global def with no previous prototype. */ else if (warn_missing_prototypes @@ -6517,13 +6444,6 @@ finish_function (nested, can_defer_p) && DECL_INLINE (fndecl)) warning ("no return statement in function returning non-void"); - /* With just -W, complain only if function returns both with - and without a value. */ - if (extra_warnings - && current_function_returns_value - && current_function_returns_null) - warning ("this function may return with or without a value"); - /* Clear out memory we no longer need. */ free_after_parsing (cfun); /* Since we never call rest_of_compilation, we never clear @@ -6708,6 +6628,13 @@ c_expand_body (fndecl, nested_p, can_defer_p) if (nested_p) ggc_pop_context (); + /* With just -W, complain only if function returns both with + and without a value. */ + if (extra_warnings + && current_function_returns_value + && current_function_returns_null) + warning ("this function may return with or without a value"); + /* If requested, warn about function definitions where the function will return a value (usually of some struct or union type) which itself will take up a lot of stack space. */ |