Deleted Added
sdiff udiff text old ( 149846 ) new ( 161660 )
full compact
1/* Process declarations and variables for C compiler.
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free

--- 5 unchanged lines hidden (view full) ---

14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
21
22/* $FreeBSD: head/contrib/gcc/c-decl.c 149846 2005-09-07 09:23:39Z obrien $ */
23
24/* Process declarations and symbol lookup for C front end.
25 Also constructs types; the standard scalar types at initialization,
26 and structure, union, array and enum types when they are declared. */
27
28/* ??? not all decl nodes are given the most useful possible
29 line numbers. For example, the CONST_DECLs for enum values. */
30

--- 921 unchanged lines hidden (view full) ---

952 warning ("%Jbuilt-in function '%D' declared as non-function",
953 newdecl, newdecl);
954 else if (warn_shadow)
955 warning ("%Jshadowing built-in function '%D'",
956 newdecl, newdecl);
957 return false;
958 }
959
960 if (!comptypes (oldtype, newtype, COMPARE_STRICT))
961 {
962 if (TREE_CODE (olddecl) == FUNCTION_DECL
963 && DECL_BUILT_IN (olddecl) && C_DECL_INVISIBLE (olddecl))
964 {
965 /* Accept harmless mismatch in function types.
966 This is for the ffs and fprintf builtins. */
967 tree trytype = match_builtin_function_types (newtype, oldtype);

--- 1983 unchanged lines hidden (view full) ---

2951
2952/* Given a parsed parameter declaration, decode it into a PARM_DECL
2953 and push that on the current scope. */
2954
2955void
2956push_parm_decl (tree parm)
2957{
2958 tree decl;
2959
2960 /* Don't attempt to expand sizes while parsing this decl.
2961 (We can get here with i_s_e 1 somehow from Objective-C.) */
2962 int save_immediate_size_expand = immediate_size_expand;
2963 immediate_size_expand = 0;
2964
2965 decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
2966 TREE_PURPOSE (TREE_PURPOSE (parm)),
2967 PARM, 0, NULL);
2968 decl_attributes (&decl, TREE_VALUE (parm), 0);
2969
2970 decl = pushdecl (decl);
2971
2972 finish_decl (decl, NULL_TREE, NULL_TREE);
2973
2974 immediate_size_expand = save_immediate_size_expand;
2975}
2976
2977/* Mark all the parameter declarations to date as forward decls,
2978 shift them to the variables list, and reset the parameters list.
2979 Also diagnose use of this extension. */
2980
2981void

--- 1797 unchanged lines hidden (view full) ---

4779 (as a forward reference), just return it. */
4780
4781 tree ref = 0;
4782
4783 if (name != 0)
4784 ref = lookup_tag (code, name, 1);
4785 if (ref && TREE_CODE (ref) == code)
4786 {
4787 if (TYPE_FIELDS (ref))
4788 {
4789 if (code == UNION_TYPE)
4790 error ("redefinition of `union %s'", IDENTIFIER_POINTER (name));
4791 else
4792 error ("redefinition of `struct %s'", IDENTIFIER_POINTER (name));
4793 }
4794 }
4795 else
4796 {
4797 /* Otherwise create a forward-reference just so the tag is in scope. */
4798
4799 ref = make_node (code);
4800 pushtag (name, ref);
4801 }

--- 198 unchanged lines hidden (view full) ---

5000 treated in some ways as volatile. */
5001 if (TREE_THIS_VOLATILE (x))
5002 C_TYPE_FIELDS_VOLATILE (t) = 1;
5003
5004 /* Any field of nominal variable size implies structure is too. */
5005 if (C_DECL_VARIABLE_SIZE (x))
5006 C_TYPE_VARIABLE_SIZE (t) = 1;
5007
5008 /* Detect invalid nested redefinition. */
5009 if (TREE_TYPE (x) == t)
5010 error ("nested redefinition of `%s'",
5011 IDENTIFIER_POINTER (TYPE_NAME (t)));
5012
5013 if (DECL_INITIAL (x))
5014 {
5015 unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1);
5016 DECL_SIZE (x) = bitsize_int (width);
5017 DECL_BIT_FIELD (x) = 1;
5018 SET_DECL_C_BIT_FIELD (x);
5019 }
5020

--- 105 unchanged lines hidden (view full) ---

5126 }
5127
5128 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
5129 {
5130 TYPE_FIELDS (x) = TYPE_FIELDS (t);
5131 TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
5132 TYPE_ALIGN (x) = TYPE_ALIGN (t);
5133 TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t);
5134 }
5135
5136 /* If this was supposed to be a transparent union, but we can't
5137 make it one, warn and turn off the flag. */
5138 if (TREE_CODE (t) == UNION_TYPE
5139 && TYPE_TRANSPARENT_UNION (t)
5140 && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
5141 {

--- 57 unchanged lines hidden (view full) ---

5199 enumtype = lookup_tag (ENUMERAL_TYPE, name, 1);
5200
5201 if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
5202 {
5203 enumtype = make_node (ENUMERAL_TYPE);
5204 pushtag (name, enumtype);
5205 }
5206
5207 C_TYPE_BEING_DEFINED (enumtype) = 1;
5208
5209 if (TYPE_VALUES (enumtype) != 0)
5210 {
5211 /* This enum is a named one that has been declared already. */
5212 error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name));
5213
5214 /* Completely replace its old definition.

--- 756 unchanged lines hidden (view full) ---

5971 For an old-style definition, construct a prototype out of the old-style
5972 parameter declarations and inject it into the function's type. */
5973
5974void
5975store_parm_decls (void)
5976{
5977 tree fndecl = current_function_decl;
5978
5979 /* The function containing FNDECL, if any. */
5980 tree context = decl_function_context (fndecl);
5981
5982 /* True if this definition is written with a prototype. */
5983 bool prototype = (current_function_parms
5984 && TREE_CODE (current_function_parms) != TREE_LIST);
5985
5986 if (prototype)
5987 store_parm_decls_newstyle ();
5988 else
5989 store_parm_decls_oldstyle ();

--- 8 unchanged lines hidden (view full) ---

5998 gen_aux_info_record (fndecl, 1, 0, prototype);
5999
6000 /* Initialize the RTL code for the function. */
6001 allocate_struct_function (fndecl);
6002
6003 /* Begin the statement tree for this function. */
6004 begin_stmt_tree (&DECL_SAVED_TREE (fndecl));
6005
6006 /* If this is a nested function, save away the sizes of any
6007 variable-size types so that we can expand them when generating
6008 RTL. */
6009 if (context)
6010 {
6011 tree t;
6012
6013 DECL_LANG_SPECIFIC (fndecl)->pending_sizes
6014 = nreverse (get_pending_sizes ());
6015 for (t = DECL_LANG_SPECIFIC (fndecl)->pending_sizes;
6016 t;
6017 t = TREE_CHAIN (t))
6018 SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = context;
6019 }
6020
6021 /* This function is being processed in whole-function mode. */
6022 cfun->x_whole_function_mode_p = 1;
6023
6024 /* Even though we're inside a function body, we still don't want to
6025 call expand_expr to calculate the size of a variable-sized array.
6026 We haven't necessarily assigned RTL to all variables yet, so it's
6027 not safe to try to expand expressions involving them. */
6028 immediate_size_expand = 0;

--- 133 unchanged lines hidden (view full) ---

6162/* Generate the RTL for the body of FNDECL. If NESTED_P is nonzero,
6163 then we are already in the process of generating RTL for another
6164 function. */
6165
6166static void
6167c_expand_body_1 (tree fndecl, int nested_p)
6168{
6169 if (nested_p)
6170 {
6171 /* Make sure that we will evaluate variable-sized types involved
6172 in our function's type. */
6173 expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
6174
6175 /* Squirrel away our current state. */
6176 push_function_context ();
6177 }
6178
6179 tree_rest_of_compilation (fndecl, nested_p);
6180
6181 if (nested_p)
6182 /* Return to the enclosing function. */
6183 pop_function_context ();
6184
6185 if (DECL_STATIC_CONSTRUCTOR (fndecl))
6186 {

--- 204 unchanged lines hidden (view full) ---

6391 statement tree. */
6392
6393tree
6394c_begin_compound_stmt (void)
6395{
6396 tree stmt;
6397
6398 /* Create the COMPOUND_STMT. */
6399 stmt = add_stmt (build_stmt (COMPOUND_STMT, NULL_TREE));
6400
6401 return stmt;
6402}
6403
6404/* Expand T (a DECL_STMT) if it declares an entity not handled by the
6405 common code. */
6406
6407void

--- 262 unchanged lines hidden ---