Deleted Added
full compact
c-decl.c (149846) c-decl.c (161660)
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
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 $ */
22/* $FreeBSD: head/contrib/gcc/c-decl.c 161660 2006-08-26 21:37:21Z kan $ */
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
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 /* Enumerators have no linkage, so may only be declared once in a
961 given scope. */
962 if (TREE_CODE (olddecl) == CONST_DECL)
963 {
964 error ("%Jredeclaration of enumerator `%D'", newdecl, newdecl);
965 locate_old_decl (olddecl, error);
966 return false;
967 }
968
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;
969 if (!comptypes (oldtype, newtype, COMPARE_STRICT))
970 {
971 if (TREE_CODE (olddecl) == FUNCTION_DECL
972 && DECL_BUILT_IN (olddecl) && C_DECL_INVISIBLE (olddecl))
973 {
974 /* Accept harmless mismatch in function types.
975 This is for the ffs and fprintf builtins. */
976 tree trytype = match_builtin_function_types (newtype, oldtype);

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

2960
2961/* Given a parsed parameter declaration, decode it into a PARM_DECL
2962 and push that on the current scope. */
2963
2964void
2965push_parm_decl (tree parm)
2966{
2967 tree decl;
2968 int old_dont_save_pending_sizes_p = 0;
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
2969
2970 /* Don't attempt to expand sizes while parsing this decl.
2971 (We can get here with i_s_e 1 somehow from Objective-C.) */
2972 int save_immediate_size_expand = immediate_size_expand;
2973 immediate_size_expand = 0;
2974
2975 /* If this is a nested function, we do want to keep SAVE_EXPRs for
2976 the argument sizes, regardless of the parent's setting. */
2977 if (cfun)
2978 {
2979 old_dont_save_pending_sizes_p = cfun->x_dont_save_pending_sizes_p;
2980 cfun->x_dont_save_pending_sizes_p = 0;
2981 }
2982
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
2983 decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)),
2984 TREE_PURPOSE (TREE_PURPOSE (parm)),
2985 PARM, 0, NULL);
2986 decl_attributes (&decl, TREE_VALUE (parm), 0);
2987
2988 decl = pushdecl (decl);
2989
2990 finish_decl (decl, NULL_TREE, NULL_TREE);
2991
2992 if (cfun)
2993 cfun->x_dont_save_pending_sizes_p = old_dont_save_pending_sizes_p;
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 {
2994 immediate_size_expand = save_immediate_size_expand;
2995}
2996
2997/* Mark all the parameter declarations to date as forward decls,
2998 shift them to the variables list, and reset the parameters list.
2999 Also diagnose use of this extension. */
3000
3001void

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

4799 (as a forward reference), just return it. */
4800
4801 tree ref = 0;
4802
4803 if (name != 0)
4804 ref = lookup_tag (code, name, 1);
4805 if (ref && TREE_CODE (ref) == code)
4806 {
4787 if (TYPE_FIELDS (ref))
4807 if (TYPE_SIZE (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 }
4808 {
4809 if (code == UNION_TYPE)
4810 error ("redefinition of `union %s'", IDENTIFIER_POINTER (name));
4811 else
4812 error ("redefinition of `struct %s'", IDENTIFIER_POINTER (name));
4813 }
4814 else if (C_TYPE_BEING_DEFINED (ref))
4815 {
4816 if (code == UNION_TYPE)
4817 error ("nested redefinition of `union %s'",
4818 IDENTIFIER_POINTER (name));
4819 else
4820 error ("nested redefinition of `struct %s'",
4821 IDENTIFIER_POINTER (name));
4822 }
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
4823 }
4824 else
4825 {
4826 /* Otherwise create a forward-reference just so the tag is in scope. */
4827
4828 ref = make_node (code);
4829 pushtag (name, ref);
4830 }

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

5029 treated in some ways as volatile. */
5030 if (TREE_THIS_VOLATILE (x))
5031 C_TYPE_FIELDS_VOLATILE (t) = 1;
5032
5033 /* Any field of nominal variable size implies structure is too. */
5034 if (C_DECL_VARIABLE_SIZE (x))
5035 C_TYPE_VARIABLE_SIZE (t) = 1;
5036
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);
5037 if (DECL_INITIAL (x))
5038 {
5039 unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1);
5040 DECL_SIZE (x) = bitsize_int (width);
5041 DECL_BIT_FIELD (x) = 1;
5042 SET_DECL_C_BIT_FIELD (x);
5043 }
5044

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

5150 }
5151
5152 for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
5153 {
5154 TYPE_FIELDS (x) = TYPE_FIELDS (t);
5155 TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
5156 TYPE_ALIGN (x) = TYPE_ALIGN (t);
5157 TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t);
5158 C_TYPE_FIELDS_READONLY (x) = C_TYPE_FIELDS_READONLY (t);
5159 C_TYPE_FIELDS_VOLATILE (x) = C_TYPE_FIELDS_VOLATILE (t);
5160 C_TYPE_VARIABLE_SIZE (x) = C_TYPE_VARIABLE_SIZE (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
5161 }
5162
5163 /* If this was supposed to be a transparent union, but we can't
5164 make it one, warn and turn off the flag. */
5165 if (TREE_CODE (t) == UNION_TYPE
5166 && TYPE_TRANSPARENT_UNION (t)
5167 && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))))
5168 {

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

5226 enumtype = lookup_tag (ENUMERAL_TYPE, name, 1);
5227
5228 if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
5229 {
5230 enumtype = make_node (ENUMERAL_TYPE);
5231 pushtag (name, enumtype);
5232 }
5233
5234 if (C_TYPE_BEING_DEFINED (enumtype))
5235 error ("nested redefinition of `enum %s'", IDENTIFIER_POINTER (name));
5236
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
5237 C_TYPE_BEING_DEFINED (enumtype) = 1;
5238
5239 if (TYPE_VALUES (enumtype) != 0)
5240 {
5241 /* This enum is a named one that has been declared already. */
5242 error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name));
5243
5244 /* Completely replace its old definition.

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

6001 For an old-style definition, construct a prototype out of the old-style
6002 parameter declarations and inject it into the function's type. */
6003
6004void
6005store_parm_decls (void)
6006{
6007 tree fndecl = current_function_decl;
6008
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
6009 /* True if this definition is written with a prototype. */
6010 bool prototype = (current_function_parms
6011 && TREE_CODE (current_function_parms) != TREE_LIST);
6012
6013 if (prototype)
6014 store_parm_decls_newstyle ();
6015 else
6016 store_parm_decls_oldstyle ();

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

6025 gen_aux_info_record (fndecl, 1, 0, prototype);
6026
6027 /* Initialize the RTL code for the function. */
6028 allocate_struct_function (fndecl);
6029
6030 /* Begin the statement tree for this function. */
6031 begin_stmt_tree (&DECL_SAVED_TREE (fndecl));
6032
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;
6033 /* Save away the sizes of any variable-size types so that we can
6034 expand them when generating RTL. */
6035 DECL_LANG_SPECIFIC (fndecl)->pending_sizes = get_pending_sizes ();
6012
6036
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)
6037 /* This function is being processed in whole-function mode. */
6038 cfun->x_whole_function_mode_p = 1;
6039
6040 /* Even though we're inside a function body, we still don't want to
6041 call expand_expr to calculate the size of a variable-sized array.
6042 We haven't necessarily assigned RTL to all variables yet, so it's
6043 not safe to try to expand expressions involving them. */
6044 immediate_size_expand = 0;

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

6178/* Generate the RTL for the body of FNDECL. If NESTED_P is nonzero,
6179 then we are already in the process of generating RTL for another
6180 function. */
6181
6182static void
6183c_expand_body_1 (tree fndecl, int nested_p)
6184{
6185 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 }
6186 /* Squirrel away our current state. */
6187 push_function_context ();
6178
6188
6189 /* Make sure that we will evaluate variable-sized types involved
6190 in our function's type. */
6191 put_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes);
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. */
6192 tree_rest_of_compilation (fndecl, nested_p);
6193
6194 if (nested_p)
6195 /* Return to the enclosing function. */
6196 pop_function_context ();
6197
6198 if (DECL_STATIC_CONSTRUCTOR (fndecl))
6199 {

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

6404 statement tree. */
6405
6406tree
6407c_begin_compound_stmt (void)
6408{
6409 tree stmt;
6410
6411 /* Create the COMPOUND_STMT. */
6399 stmt = add_stmt (build_stmt (COMPOUND_STMT, NULL_TREE));
6412 stmt = add_stmt (build_stmt (COMPOUND_STMT, error_mark_node));
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 ---
6413
6414 return stmt;
6415}
6416
6417/* Expand T (a DECL_STMT) if it declares an entity not handled by the
6418 common code. */
6419
6420void

--- 262 unchanged lines hidden ---