c-decl.c (132730) | c-decl.c (146906) |
---|---|
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 132730 2004-07-28 03:53:20Z kan $ */ | 22/* $FreeBSD: head/contrib/gcc/c-decl.c 146906 2005-06-03 03:50:42Z 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 --- 3586 unchanged lines hidden (view full) --- 3617 else 3618 { 3619 if (pedantic) 3620 pedwarn ("ISO C does not support complex integer types"); 3621 type = build_complex_type (type); 3622 } 3623 } 3624 | 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 --- 3586 unchanged lines hidden (view full) --- 3617 else 3618 { 3619 if (pedantic) 3620 pedwarn ("ISO C does not support complex integer types"); 3621 type = build_complex_type (type); 3622 } 3623 } 3624 |
3625 /* Check the type and width of a bit-field. */ 3626 if (bitfield) 3627 check_bitfield_type_and_width (&type, width, orig_name); 3628 | |
3629 /* Figure out the type qualifiers for the declaration. There are 3630 two ways a declaration can become qualified. One is something 3631 like `const int i' where the `const' is explicit. Another is 3632 something like `typedef const int CI; CI i' where the type of the 3633 declaration contains the `const'. A third possibility is that 3634 there is a type qualifier on the element type of a typedefed 3635 array type, in which case we should extract that qualifier so 3636 that c_apply_type_quals_to_decls receives the full list of --- 343 unchanged lines hidden (view full) --- 3980 { 3981 error ("static or type qualifiers in non-parameter array declarator"); 3982 array_ptr_quals = NULL_TREE; 3983 array_parm_static = 0; 3984 } 3985 } 3986 else if (TREE_CODE (declarator) == CALL_EXPR) 3987 { | 3625 /* Figure out the type qualifiers for the declaration. There are 3626 two ways a declaration can become qualified. One is something 3627 like `const int i' where the `const' is explicit. Another is 3628 something like `typedef const int CI; CI i' where the type of the 3629 declaration contains the `const'. A third possibility is that 3630 there is a type qualifier on the element type of a typedefed 3631 array type, in which case we should extract that qualifier so 3632 that c_apply_type_quals_to_decls receives the full list of --- 343 unchanged lines hidden (view full) --- 3976 { 3977 error ("static or type qualifiers in non-parameter array declarator"); 3978 array_ptr_quals = NULL_TREE; 3979 array_parm_static = 0; 3980 } 3981 } 3982 else if (TREE_CODE (declarator) == CALL_EXPR) 3983 { |
3984 /* Say it's a definition only for the declarator closest to 3985 the identifier, apart possibly from some attributes. */ 3986 bool really_funcdef = false; |
|
3988 tree arg_types; | 3987 tree arg_types; |
3988 if (funcdef_flag) 3989 { 3990 tree t = TREE_OPERAND (declarator, 0); 3991 while (TREE_CODE (t) == TREE_LIST) 3992 t = TREE_VALUE (t); 3993 really_funcdef = (TREE_CODE (t) == IDENTIFIER_NODE); 3994 } |
|
3989 3990 /* Declaring a function type. 3991 Make sure we have a valid type for the function to return. */ 3992 if (type == error_mark_node) 3993 continue; 3994 3995 size_varies = 0; 3996 --- 9 unchanged lines hidden (view full) --- 4006 error ("`%s' declared as function returning an array", name); 4007 type = integer_type_node; 4008 } 4009 4010 /* Construct the function type and go to the next 4011 inner layer of declarator. */ 4012 4013 arg_types = grokparms (TREE_OPERAND (declarator, 1), | 3995 3996 /* Declaring a function type. 3997 Make sure we have a valid type for the function to return. */ 3998 if (type == error_mark_node) 3999 continue; 4000 4001 size_varies = 0; 4002 --- 9 unchanged lines hidden (view full) --- 4012 error ("`%s' declared as function returning an array", name); 4013 type = integer_type_node; 4014 } 4015 4016 /* Construct the function type and go to the next 4017 inner layer of declarator. */ 4018 4019 arg_types = grokparms (TREE_OPERAND (declarator, 1), |
4014 funcdef_flag 4015 /* Say it's a definition 4016 only for the CALL_EXPR 4017 closest to the identifier. */ 4018 && TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE); | 4020 really_funcdef); |
4019 /* Type qualifiers before the return type of the function 4020 qualify the return type, not the function type. */ 4021 if (type_quals) 4022 { 4023 /* Type qualifiers on a function return type are normally 4024 permitted by the standard but have no effect, so give a 4025 warning at -Wextra. Qualifiers on a void return type have 4026 meaning as a GNU extension, and are banned on function --- 97 unchanged lines hidden (view full) --- 4124 } 4125 else 4126 abort (); 4127 4128 } 4129 4130 /* Now TYPE has the actual type. */ 4131 | 4021 /* Type qualifiers before the return type of the function 4022 qualify the return type, not the function type. */ 4023 if (type_quals) 4024 { 4025 /* Type qualifiers on a function return type are normally 4026 permitted by the standard but have no effect, so give a 4027 warning at -Wextra. Qualifiers on a void return type have 4028 meaning as a GNU extension, and are banned on function --- 97 unchanged lines hidden (view full) --- 4126 } 4127 else 4128 abort (); 4129 4130 } 4131 4132 /* Now TYPE has the actual type. */ 4133 |
4134 /* Check the type and width of a bit-field. */ 4135 if (bitfield) 4136 check_bitfield_type_and_width (&type, width, orig_name); 4137 |
|
4132 /* Did array size calculations overflow? */ 4133 4134 if (TREE_CODE (type) == ARRAY_TYPE 4135 && COMPLETE_TYPE_P (type) 4136 && TREE_OVERFLOW (TYPE_SIZE (type))) 4137 { 4138 error ("size of array `%s' is too large", name); 4139 /* If we proceed with the array type as it is, we'll eventually --- 983 unchanged lines hidden (view full) --- 5123 TYPE_ALIGN (x) = TYPE_ALIGN (t); 5124 TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t); 5125 } 5126 5127 /* If this was supposed to be a transparent union, but we can't 5128 make it one, warn and turn off the flag. */ 5129 if (TREE_CODE (t) == UNION_TYPE 5130 && TYPE_TRANSPARENT_UNION (t) | 4138 /* Did array size calculations overflow? */ 4139 4140 if (TREE_CODE (type) == ARRAY_TYPE 4141 && COMPLETE_TYPE_P (type) 4142 && TREE_OVERFLOW (TYPE_SIZE (type))) 4143 { 4144 error ("size of array `%s' is too large", name); 4145 /* If we proceed with the array type as it is, we'll eventually --- 983 unchanged lines hidden (view full) --- 5129 TYPE_ALIGN (x) = TYPE_ALIGN (t); 5130 TYPE_USER_ALIGN (x) = TYPE_USER_ALIGN (t); 5131 } 5132 5133 /* If this was supposed to be a transparent union, but we can't 5134 make it one, warn and turn off the flag. */ 5135 if (TREE_CODE (t) == UNION_TYPE 5136 && TYPE_TRANSPARENT_UNION (t) |
5131 && TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t))) | 5137 && (!TYPE_FIELDS (t) || TYPE_MODE (t) != DECL_MODE (TYPE_FIELDS (t)))) |
5132 { 5133 TYPE_TRANSPARENT_UNION (t) = 0; 5134 warning ("union cannot be made transparent"); 5135 } 5136 5137 /* If this structure or union completes the type of any previous 5138 variable declaration, lay it out and output its rtl. */ 5139 for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)); --- 135 unchanged lines hidden (view full) --- 5275 5276 if (precision == TYPE_PRECISION (integer_type_node)) 5277 enum_value_type = c_common_type_for_size (precision, 0); 5278 else 5279 enum_value_type = enumtype; 5280 5281 TYPE_MIN_VALUE (enumtype) = minnode; 5282 TYPE_MAX_VALUE (enumtype) = maxnode; | 5138 { 5139 TYPE_TRANSPARENT_UNION (t) = 0; 5140 warning ("union cannot be made transparent"); 5141 } 5142 5143 /* If this structure or union completes the type of any previous 5144 variable declaration, lay it out and output its rtl. */ 5145 for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)); --- 135 unchanged lines hidden (view full) --- 5281 5282 if (precision == TYPE_PRECISION (integer_type_node)) 5283 enum_value_type = c_common_type_for_size (precision, 0); 5284 else 5285 enum_value_type = enumtype; 5286 5287 TYPE_MIN_VALUE (enumtype) = minnode; 5288 TYPE_MAX_VALUE (enumtype) = maxnode; |
5283 TYPE_PRECISION (enumtype) = precision; | |
5284 TREE_UNSIGNED (enumtype) = unsign; 5285 TYPE_SIZE (enumtype) = 0; | 5289 TREE_UNSIGNED (enumtype) = unsign; 5290 TYPE_SIZE (enumtype) = 0; |
5291 5292 /* If the precision of the type was specific with an attribute and it 5293 was too small, give an error. Otherwise, use it. */ 5294 if (TYPE_PRECISION (enumtype)) 5295 { 5296 if (precision > TYPE_PRECISION (enumtype)) 5297 error ("specified mode too small for enumeral values"); 5298 } 5299 else 5300 TYPE_PRECISION (enumtype) = precision; 5301 |
|
5286 layout_type (enumtype); 5287 5288 if (values != error_mark_node) 5289 { 5290 /* Change the type of the enumerators to be the enum type. We 5291 need to do this irrespective of the size of the enum, for 5292 proper type checking. Replace the DECL_INITIALs of the 5293 enumerators, and the value slots of the list, with copies --- 1357 unchanged lines hidden --- | 5302 layout_type (enumtype); 5303 5304 if (values != error_mark_node) 5305 { 5306 /* Change the type of the enumerators to be the enum type. We 5307 need to do this irrespective of the size of the enum, for 5308 proper type checking. Replace the DECL_INITIALs of the 5309 enumerators, and the value slots of the list, with copies --- 1357 unchanged lines hidden --- |