Deleted Added
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 $ */
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
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
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;
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
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;
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))
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 }
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
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);
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
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
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 ();
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
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 ();
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);
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));
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 ---