decl.c (132747) | decl.c (146906) |
---|---|
1/* Process declarations and variables for C++ compiler. 2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | 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. | 3 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
4 Contributed by Michael Tiemann (tiemann@cygnus.com) 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2, or (at your option) 11any later version. --- 102 unchanged lines hidden (view full) --- 114static tree push_cp_library_fn (enum tree_code, tree); 115static tree build_cp_library_fn (tree, enum tree_code, tree); 116static void store_parm_decls (tree); 117static int cp_missing_noreturn_ok_p (tree); 118static void initialize_local_var (tree, tree); 119static void expand_static_init (tree, tree); 120static tree next_initializable_field (tree); 121static tree reshape_init (tree, tree *); | 4 Contributed by Michael Tiemann (tiemann@cygnus.com) 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2, or (at your option) 11any later version. --- 102 unchanged lines hidden (view full) --- 114static tree push_cp_library_fn (enum tree_code, tree); 115static tree build_cp_library_fn (tree, enum tree_code, tree); 116static void store_parm_decls (tree); 117static int cp_missing_noreturn_ok_p (tree); 118static void initialize_local_var (tree, tree); 119static void expand_static_init (tree, tree); 120static tree next_initializable_field (tree); 121static tree reshape_init (tree, tree *); |
122static bool reshape_init_array (tree, tree, tree *, tree); |
|
122static tree build_typename_type (tree, tree, tree); 123 124/* Erroneous argument lists can use this *IFF* they do not modify it. */ 125tree error_mark_list; 126 127/* The following symbols are subsumed in the cp_global_trees array, and 128 listed here individually for documentation purposes. 129 --- 932 unchanged lines hidden (view full) --- 1062 types_match = same_type_p (TREE_TYPE (DECL_TEMPLATE_RESULT (olddecl)), 1063 TREE_TYPE (DECL_TEMPLATE_RESULT (newdecl))); 1064 else 1065 types_match = decls_match (DECL_TEMPLATE_RESULT (olddecl), 1066 DECL_TEMPLATE_RESULT (newdecl)); 1067 } 1068 else 1069 { | 123static tree build_typename_type (tree, tree, tree); 124 125/* Erroneous argument lists can use this *IFF* they do not modify it. */ 126tree error_mark_list; 127 128/* The following symbols are subsumed in the cp_global_trees array, and 129 listed here individually for documentation purposes. 130 --- 932 unchanged lines hidden (view full) --- 1063 types_match = same_type_p (TREE_TYPE (DECL_TEMPLATE_RESULT (olddecl)), 1064 TREE_TYPE (DECL_TEMPLATE_RESULT (newdecl))); 1065 else 1066 types_match = decls_match (DECL_TEMPLATE_RESULT (olddecl), 1067 DECL_TEMPLATE_RESULT (newdecl)); 1068 } 1069 else 1070 { |
1071 /* Need to check scope for variable declaration (VAR_DECL). 1072 For typedef (TYPE_DECL), scope is ignored. */ 1073 if (TREE_CODE (newdecl) == VAR_DECL 1074 && CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl)) 1075 return 0; 1076 |
|
1070 if (TREE_TYPE (newdecl) == error_mark_node) 1071 types_match = TREE_TYPE (olddecl) == error_mark_node; 1072 else if (TREE_TYPE (olddecl) == NULL_TREE) 1073 types_match = TREE_TYPE (newdecl) == NULL_TREE; 1074 else if (TREE_TYPE (newdecl) == NULL_TREE) 1075 types_match = 0; 1076 else 1077 types_match = comptypes (TREE_TYPE (newdecl), --- 327 unchanged lines hidden (view full) --- 1405 else if (TREE_CODE (newdecl) == FUNCTION_DECL 1406 && ((DECL_TEMPLATE_INSTANTIATION (olddecl) 1407 && !DECL_USE_TEMPLATE (newdecl)) 1408 || (DECL_TEMPLATE_INSTANTIATION (newdecl) 1409 && !DECL_USE_TEMPLATE (olddecl)))) 1410 /* One of the declarations is a template instantiation, and the 1411 other is not a template at all. That's OK. */ 1412 return NULL_TREE; | 1077 if (TREE_TYPE (newdecl) == error_mark_node) 1078 types_match = TREE_TYPE (olddecl) == error_mark_node; 1079 else if (TREE_TYPE (olddecl) == NULL_TREE) 1080 types_match = TREE_TYPE (newdecl) == NULL_TREE; 1081 else if (TREE_TYPE (newdecl) == NULL_TREE) 1082 types_match = 0; 1083 else 1084 types_match = comptypes (TREE_TYPE (newdecl), --- 327 unchanged lines hidden (view full) --- 1412 else if (TREE_CODE (newdecl) == FUNCTION_DECL 1413 && ((DECL_TEMPLATE_INSTANTIATION (olddecl) 1414 && !DECL_USE_TEMPLATE (newdecl)) 1415 || (DECL_TEMPLATE_INSTANTIATION (newdecl) 1416 && !DECL_USE_TEMPLATE (olddecl)))) 1417 /* One of the declarations is a template instantiation, and the 1418 other is not a template at all. That's OK. */ 1419 return NULL_TREE; |
1413 else if (TREE_CODE (newdecl) == NAMESPACE_DECL 1414 && DECL_NAMESPACE_ALIAS (newdecl) 1415 && DECL_NAMESPACE_ALIAS (newdecl) == DECL_NAMESPACE_ALIAS (olddecl)) 1416 /* In [namespace.alias] we have: | 1420 else if (TREE_CODE (newdecl) == NAMESPACE_DECL) 1421 { 1422 /* In [namespace.alias] we have: 1423 1424 In a declarative region, a namespace-alias-definition can be 1425 used to redefine a namespace-alias declared in that declarative 1426 region to refer only to the namespace to which it already 1427 refers. 1428 1429 Therefore, if we encounter a second alias directive for the same 1430 alias, we can just ignore the second directive. */ 1431 if (DECL_NAMESPACE_ALIAS (newdecl) 1432 && (DECL_NAMESPACE_ALIAS (newdecl) 1433 == DECL_NAMESPACE_ALIAS (olddecl))) 1434 return olddecl; 1435 /* [namespace.alias] |
1417 | 1436 |
1418 In a declarative region, a namespace-alias-definition can be 1419 used to redefine a namespace-alias declared in that declarative 1420 region to refer only to the namespace to which it already 1421 refers. 1422 1423 Therefore, if we encounter a second alias directive for the same 1424 alias, we can just ignore the second directive. */ 1425 return olddecl; | 1437 A namespace-name or namespace-alias shall not be declared as 1438 the name of any other entity in the same declarative region. 1439 A namespace-name defined at global scope shall not be 1440 declared as the name of any other entity in any glogal scope 1441 of the program. */ 1442 error ("declaration of `namespace %D' conflicts with", newdecl); 1443 cp_error_at ("previous declaration of `namespace %D' here", olddecl); 1444 return error_mark_node; 1445 } |
1426 else 1427 { 1428 const char *errmsg = redeclaration_error_message (newdecl, olddecl); 1429 if (errmsg) 1430 { 1431 error (errmsg, newdecl); 1432 if (DECL_NAME (olddecl) != NULL_TREE) 1433 cp_error_at ((DECL_INITIAL (olddecl) --- 570 unchanged lines hidden (view full) --- 2004 the original initialization to `0' (which we force to call 2005 abort()). Don't complain about redefinition in this case. */ 2006 if (DECL_LANG_SPECIFIC (olddecl) && DECL_PURE_VIRTUAL_P (olddecl)) 2007 return 0; 2008 2009 /* If both functions come from different namespaces, this is not 2010 a redeclaration - this is a conflict with a used function. */ 2011 if (DECL_NAMESPACE_SCOPE_P (olddecl) | 1446 else 1447 { 1448 const char *errmsg = redeclaration_error_message (newdecl, olddecl); 1449 if (errmsg) 1450 { 1451 error (errmsg, newdecl); 1452 if (DECL_NAME (olddecl) != NULL_TREE) 1453 cp_error_at ((DECL_INITIAL (olddecl) --- 570 unchanged lines hidden (view full) --- 2024 the original initialization to `0' (which we force to call 2025 abort()). Don't complain about redefinition in this case. */ 2026 if (DECL_LANG_SPECIFIC (olddecl) && DECL_PURE_VIRTUAL_P (olddecl)) 2027 return 0; 2028 2029 /* If both functions come from different namespaces, this is not 2030 a redeclaration - this is a conflict with a used function. */ 2031 if (DECL_NAMESPACE_SCOPE_P (olddecl) |
2012 && DECL_CONTEXT (olddecl) != DECL_CONTEXT (newdecl)) | 2032 && DECL_CONTEXT (olddecl) != DECL_CONTEXT (newdecl) 2033 && ! decls_match (olddecl, newdecl)) |
2013 return "`%D' conflicts with used function"; 2014 2015 /* We'll complain about linkage mismatches in 2016 warn_extern_redeclared_static. */ 2017 2018 /* Defining the same name twice is no good. */ 2019 if (DECL_INITIAL (olddecl) != NULL_TREE 2020 && DECL_INITIAL (newdecl) != NULL_TREE) --- 1664 unchanged lines hidden (view full) --- 3685 attributes = chainon (attributes, prefix_attributes); 3686 3687 decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, 3688 &attributes); 3689 3690 deprecated_state = DEPRECATED_NORMAL; 3691 3692 if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE) | 2034 return "`%D' conflicts with used function"; 2035 2036 /* We'll complain about linkage mismatches in 2037 warn_extern_redeclared_static. */ 2038 2039 /* Defining the same name twice is no good. */ 2040 if (DECL_INITIAL (olddecl) != NULL_TREE 2041 && DECL_INITIAL (newdecl) != NULL_TREE) --- 1664 unchanged lines hidden (view full) --- 3706 attributes = chainon (attributes, prefix_attributes); 3707 3708 decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, 3709 &attributes); 3710 3711 deprecated_state = DEPRECATED_NORMAL; 3712 3713 if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE) |
3693 return NULL_TREE; | 3714 return error_mark_node; |
3694 3695 type = TREE_TYPE (decl); 3696 3697 if (type == error_mark_node) | 3715 3716 type = TREE_TYPE (decl); 3717 3718 if (type == error_mark_node) |
3698 return NULL_TREE; | 3719 return error_mark_node; |
3699 3700 context = DECL_CONTEXT (decl); 3701 3702 if (initialized && context && TREE_CODE (context) == NAMESPACE_DECL 3703 && context != current_namespace && TREE_CODE (decl) == VAR_DECL) 3704 { 3705 /* When parsing the initializer, lookup should use the object's 3706 namespace. */ --- 471 unchanged lines hidden (view full) --- 4178 && (TREE_CODE (field) != FIELD_DECL 4179 || (DECL_C_BIT_FIELD (field) && !DECL_NAME (field)) 4180 || DECL_ARTIFICIAL (field))) 4181 field = TREE_CHAIN (field); 4182 4183 return field; 4184} 4185 | 3720 3721 context = DECL_CONTEXT (decl); 3722 3723 if (initialized && context && TREE_CODE (context) == NAMESPACE_DECL 3724 && context != current_namespace && TREE_CODE (decl) == VAR_DECL) 3725 { 3726 /* When parsing the initializer, lookup should use the object's 3727 namespace. */ --- 471 unchanged lines hidden (view full) --- 4199 && (TREE_CODE (field) != FIELD_DECL 4200 || (DECL_C_BIT_FIELD (field) && !DECL_NAME (field)) 4201 || DECL_ARTIFICIAL (field))) 4202 field = TREE_CHAIN (field); 4203 4204 return field; 4205} 4206 |
4207/* Subroutine of reshape_init. Reshape the constructor for an array. INITP 4208 is the pointer to the old constructor list (to the CONSTRUCTOR_ELTS of 4209 the CONSTRUCTOR we are processing), while NEW_INIT is the CONSTRUCTOR we 4210 are building. 4211 ELT_TYPE is the element type of the array. MAX_INDEX is an INTEGER_CST 4212 representing the size of the array minus one (the maximum index), or 4213 NULL_TREE if the array was declared without specifying the size. */ 4214 4215static bool 4216reshape_init_array (tree elt_type, tree max_index, 4217 tree *initp, tree new_init) 4218{ 4219 bool sized_array_p = (max_index != NULL_TREE); 4220 unsigned HOST_WIDE_INT max_index_cst = 0; 4221 unsigned HOST_WIDE_INT index; 4222 4223 if (sized_array_p) 4224 { 4225 if (host_integerp (max_index, 1)) 4226 max_index_cst = tree_low_cst (max_index, 1); 4227 /* sizetype is sign extended, not zero extended. */ 4228 else 4229 max_index_cst = tree_low_cst (convert (size_type_node, max_index), 1); 4230 } 4231 4232 /* Loop until there are no more initializers. */ 4233 for (index = 0; 4234 *initp && (!sized_array_p || index <= max_index_cst); 4235 ++index) 4236 { 4237 tree element_init; 4238 tree designated_index; 4239 4240 element_init = reshape_init (elt_type, initp); 4241 if (element_init == error_mark_node) 4242 return false; 4243 TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init); 4244 CONSTRUCTOR_ELTS (new_init) = element_init; 4245 designated_index = TREE_PURPOSE (element_init); 4246 if (designated_index) 4247 { 4248 /* Handle array designated initializers (GNU extension). */ 4249 if (TREE_CODE (designated_index) == IDENTIFIER_NODE) 4250 { 4251 error ("name `%D' used in a GNU-style designated " 4252 "initializer for an array", designated_index); 4253 TREE_PURPOSE (element_init) = NULL_TREE; 4254 } 4255 else 4256 abort (); 4257 } 4258 } 4259 4260 return true; 4261} 4262 |
|
4186/* Undo the brace-elision allowed by [dcl.init.aggr] in a 4187 brace-enclosed aggregate initializer. 4188 4189 *INITP is one of a list of initializers describing a brace-enclosed 4190 initializer for an entity of the indicated aggregate TYPE. It may 4191 not presently match the shape of the TYPE; for example: 4192 4193 struct S { int a; int b; }; --- 7 unchanged lines hidden (view full) --- 4201static tree 4202reshape_init (tree type, tree *initp) 4203{ 4204 tree inits; 4205 tree old_init; 4206 tree old_init_value; 4207 tree new_init; 4208 bool brace_enclosed_p; | 4263/* Undo the brace-elision allowed by [dcl.init.aggr] in a 4264 brace-enclosed aggregate initializer. 4265 4266 *INITP is one of a list of initializers describing a brace-enclosed 4267 initializer for an entity of the indicated aggregate TYPE. It may 4268 not presently match the shape of the TYPE; for example: 4269 4270 struct S { int a; int b; }; --- 7 unchanged lines hidden (view full) --- 4278static tree 4279reshape_init (tree type, tree *initp) 4280{ 4281 tree inits; 4282 tree old_init; 4283 tree old_init_value; 4284 tree new_init; 4285 bool brace_enclosed_p; |
4286 bool string_init_p; |
|
4209 4210 old_init = *initp; 4211 old_init_value = (TREE_CODE (*initp) == TREE_LIST 4212 ? TREE_VALUE (*initp) : old_init); 4213 4214 my_friendly_assert (old_init_value, 20030723); 4215 4216 /* If the initializer is brace-enclosed, pull initializers from the --- 48 unchanged lines hidden (view full) --- 4265 if (!brace_enclosed_p 4266 && can_convert_arg (type, TREE_TYPE (old_init_value), old_init_value)) 4267 { 4268 *initp = TREE_CHAIN (old_init); 4269 TREE_CHAIN (old_init) = NULL_TREE; 4270 return old_init; 4271 } 4272 | 4287 4288 old_init = *initp; 4289 old_init_value = (TREE_CODE (*initp) == TREE_LIST 4290 ? TREE_VALUE (*initp) : old_init); 4291 4292 my_friendly_assert (old_init_value, 20030723); 4293 4294 /* If the initializer is brace-enclosed, pull initializers from the --- 48 unchanged lines hidden (view full) --- 4343 if (!brace_enclosed_p 4344 && can_convert_arg (type, TREE_TYPE (old_init_value), old_init_value)) 4345 { 4346 *initp = TREE_CHAIN (old_init); 4347 TREE_CHAIN (old_init) = NULL_TREE; 4348 return old_init; 4349 } 4350 |
4351 string_init_p = false; |
|
4273 if (TREE_CODE (old_init_value) == STRING_CST 4274 && TREE_CODE (type) == ARRAY_TYPE 4275 && char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)))) 4276 { 4277 /* [dcl.init.string] 4278 4279 A char array (whether plain char, signed char, or unsigned char) 4280 can be initialized by a string-literal (optionally enclosed in 4281 braces); a wchar_t array can be initialized by a wide 4282 string-literal (optionally enclosed in braces). */ 4283 new_init = old_init; 4284 /* Move past the initializer. */ 4285 *initp = TREE_CHAIN (old_init); 4286 TREE_CHAIN (old_init) = NULL_TREE; | 4352 if (TREE_CODE (old_init_value) == STRING_CST 4353 && TREE_CODE (type) == ARRAY_TYPE 4354 && char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)))) 4355 { 4356 /* [dcl.init.string] 4357 4358 A char array (whether plain char, signed char, or unsigned char) 4359 can be initialized by a string-literal (optionally enclosed in 4360 braces); a wchar_t array can be initialized by a wide 4361 string-literal (optionally enclosed in braces). */ 4362 new_init = old_init; 4363 /* Move past the initializer. */ 4364 *initp = TREE_CHAIN (old_init); 4365 TREE_CHAIN (old_init) = NULL_TREE; |
4366 string_init_p = true; |
|
4287 } 4288 else 4289 { 4290 /* Build a CONSTRUCTOR to hold the contents of the aggregate. */ 4291 new_init = build_constructor (type, NULL_TREE); 4292 TREE_HAS_CONSTRUCTOR (new_init) = 1; 4293 4294 if (CLASS_TYPE_P (type)) --- 51 unchanged lines hidden (view full) --- 4346 if (TREE_CODE (type) == UNION_TYPE) 4347 break; 4348 field = next_initializable_field (TREE_CHAIN (field)); 4349 } 4350 } 4351 } 4352 else if ((TREE_CODE (type) == ARRAY_TYPE)|| (TREE_CODE (type) == VECTOR_TYPE)) 4353 { | 4367 } 4368 else 4369 { 4370 /* Build a CONSTRUCTOR to hold the contents of the aggregate. */ 4371 new_init = build_constructor (type, NULL_TREE); 4372 TREE_HAS_CONSTRUCTOR (new_init) = 1; 4373 4374 if (CLASS_TYPE_P (type)) --- 51 unchanged lines hidden (view full) --- 4426 if (TREE_CODE (type) == UNION_TYPE) 4427 break; 4428 field = next_initializable_field (TREE_CHAIN (field)); 4429 } 4430 } 4431 } 4432 else if ((TREE_CODE (type) == ARRAY_TYPE)|| (TREE_CODE (type) == VECTOR_TYPE)) 4433 { |
4354 tree index; | |
4355 tree max_index; 4356 4357 /* If the bound of the array is known, take no more initializers 4358 than are allowed. */ 4359 max_index = ((TYPE_DOMAIN (type) && (TREE_CODE (type) == ARRAY_TYPE)) 4360 ? array_type_nelts (type) : NULL_TREE); | 4434 tree max_index; 4435 4436 /* If the bound of the array is known, take no more initializers 4437 than are allowed. */ 4438 max_index = ((TYPE_DOMAIN (type) && (TREE_CODE (type) == ARRAY_TYPE)) 4439 ? array_type_nelts (type) : NULL_TREE); |
4361 /* Loop through the array elements, gathering initializers. */ 4362 for (index = size_zero_node; 4363 *initp && (!max_index || !tree_int_cst_lt (max_index, index)); 4364 index = size_binop (PLUS_EXPR, index, size_one_node)) 4365 { 4366 tree element_init; 4367 4368 element_init = reshape_init (TREE_TYPE (type), initp); 4369 if (element_init == error_mark_node) 4370 return error_mark_node; 4371 TREE_CHAIN (element_init) = CONSTRUCTOR_ELTS (new_init); 4372 CONSTRUCTOR_ELTS (new_init) = element_init; 4373 if (TREE_PURPOSE (element_init)) 4374 { 4375 tree next_index = TREE_PURPOSE (element_init); 4376 if (TREE_CODE (next_index) == IDENTIFIER_NODE) 4377 { 4378 error ("name `%D' used in a GNU-style designated " 4379 "initializer for an array", next_index); 4380 TREE_PURPOSE (element_init) = NULL_TREE; 4381 } 4382 else 4383 index = next_index; 4384 } 4385 } | 4440 if (!reshape_init_array (TREE_TYPE (type), max_index, 4441 initp, new_init)) 4442 return error_mark_node; |
4386 } 4387 else 4388 abort (); 4389 4390 /* The initializers were placed in reverse order in the 4391 CONSTRUCTOR. */ 4392 CONSTRUCTOR_ELTS (new_init) = nreverse (CONSTRUCTOR_ELTS (new_init)); 4393 4394 if (TREE_CODE (old_init) == TREE_LIST) 4395 new_init = build_tree_list (TREE_PURPOSE (old_init), new_init); 4396 } 4397 | 4443 } 4444 else 4445 abort (); 4446 4447 /* The initializers were placed in reverse order in the 4448 CONSTRUCTOR. */ 4449 CONSTRUCTOR_ELTS (new_init) = nreverse (CONSTRUCTOR_ELTS (new_init)); 4450 4451 if (TREE_CODE (old_init) == TREE_LIST) 4452 new_init = build_tree_list (TREE_PURPOSE (old_init), new_init); 4453 } 4454 |
4398 /* If this was a brace-enclosed initializer and all of the 4399 initializers were not used up, there is a problem. */ 4400 if (brace_enclosed_p && *initp) 4401 error ("too many initializers for `%T'", type); | 4455 /* If there are more initializers than necessary, issue a 4456 diagnostic. */ 4457 if (*initp) 4458 { 4459 if (brace_enclosed_p) 4460 error ("too many initializers for `%T'", type); 4461 else if (warn_missing_braces && !string_init_p) 4462 warning ("missing braces around initializer"); 4463 } |
4402 4403 return new_init; 4404} 4405 4406/* Verify INIT (the initializer for DECL), and record the 4407 initialization in DECL_INITIAL, if appropriate. CLEANUP is as for 4408 grok_reference_init. 4409 --- 308 unchanged lines hidden (view full) --- 4718void 4719cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags) 4720{ 4721 tree type; 4722 tree ttype = NULL_TREE; 4723 tree cleanup; 4724 const char *asmspec = NULL; 4725 int was_readonly = 0; | 4464 4465 return new_init; 4466} 4467 4468/* Verify INIT (the initializer for DECL), and record the 4469 initialization in DECL_INITIAL, if appropriate. CLEANUP is as for 4470 grok_reference_init. 4471 --- 308 unchanged lines hidden (view full) --- 4780void 4781cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags) 4782{ 4783 tree type; 4784 tree ttype = NULL_TREE; 4785 tree cleanup; 4786 const char *asmspec = NULL; 4787 int was_readonly = 0; |
4788 bool var_definition_p = false; |
|
4726 4727 if (decl == error_mark_node) 4728 return; 4729 else if (! decl) 4730 { 4731 if (init) 4732 error ("assignment (not initialization) in declaration"); 4733 return; --- 136 unchanged lines hidden (view full) --- 4870 necessary zero-initialization has already been performed. */ 4871 if (TREE_STATIC (decl) && !DECL_INITIAL (decl)) 4872 DECL_INITIAL (decl) = build_zero_init (TREE_TYPE (decl), 4873 /*nelts=*/NULL_TREE, 4874 /*static_storage_p=*/true); 4875 /* Remember that the initialization for this variable has 4876 taken place. */ 4877 DECL_INITIALIZED_P (decl) = 1; | 4789 4790 if (decl == error_mark_node) 4791 return; 4792 else if (! decl) 4793 { 4794 if (init) 4795 error ("assignment (not initialization) in declaration"); 4796 return; --- 136 unchanged lines hidden (view full) --- 4933 necessary zero-initialization has already been performed. */ 4934 if (TREE_STATIC (decl) && !DECL_INITIAL (decl)) 4935 DECL_INITIAL (decl) = build_zero_init (TREE_TYPE (decl), 4936 /*nelts=*/NULL_TREE, 4937 /*static_storage_p=*/true); 4938 /* Remember that the initialization for this variable has 4939 taken place. */ 4940 DECL_INITIALIZED_P (decl) = 1; |
4941 /* This declaration is the definition of this variable, 4942 unless we are initializing a static data member within 4943 the class specifier. */ 4944 if (!DECL_EXTERNAL (decl)) 4945 var_definition_p = true; |
|
4878 } 4879 /* If the variable has an array type, lay out the type, even if 4880 there is no initializer. It is valid to index through the 4881 array, and we must get TYPE_ALIGN set correctly on the array 4882 type. */ 4883 else if (TREE_CODE (type) == ARRAY_TYPE) 4884 layout_type (type); 4885 } --- 58 unchanged lines hidden (view full) --- 4944 { 4945 if (init || DECL_INITIAL (decl) == error_mark_node) 4946 DECL_INITIAL (decl) = init; 4947 } 4948 else if (!TREE_STATIC (decl)) 4949 initialize_local_var (decl, init); 4950 } 4951 | 4946 } 4947 /* If the variable has an array type, lay out the type, even if 4948 there is no initializer. It is valid to index through the 4949 array, and we must get TYPE_ALIGN set correctly on the array 4950 type. */ 4951 else if (TREE_CODE (type) == ARRAY_TYPE) 4952 layout_type (type); 4953 } --- 58 unchanged lines hidden (view full) --- 5012 { 5013 if (init || DECL_INITIAL (decl) == error_mark_node) 5014 DECL_INITIAL (decl) = init; 5015 } 5016 else if (!TREE_STATIC (decl)) 5017 initialize_local_var (decl, init); 5018 } 5019 |
4952 if (TREE_STATIC (decl)) 4953 expand_static_init (decl, init); | 5020 /* If a variable is defined, and then a subsequent 5021 definintion with external linkage is encountered, we will 5022 get here twice for the same variable. We want to avoid 5023 calling expand_static_init more than once. For variables 5024 that are not static data members, we can call 5025 expand_static_init only when we actually process the 5026 initializer. It is not legal to redeclare a static data 5027 member, so this issue does not arise in that case. */ 5028 if (var_definition_p && TREE_STATIC (decl)) 5029 expand_static_init (decl, init); |
4954 } 4955 finish_end0: 4956 4957 /* Undo call to `pushclass' that was done in `start_decl' 4958 due to initialization of qualified member variable. 4959 I.e., Foo::x = 10; */ 4960 { 4961 tree context = CP_DECL_CONTEXT (decl); --- 1350 unchanged lines hidden (view full) --- 6312 default: 6313 abort (); 6314 break; 6315 } 6316 6317 return type; 6318} 6319 | 5030 } 5031 finish_end0: 5032 5033 /* Undo call to `pushclass' that was done in `start_decl' 5034 due to initialization of qualified member variable. 5035 I.e., Foo::x = 10; */ 5036 { 5037 tree context = CP_DECL_CONTEXT (decl); --- 1350 unchanged lines hidden (view full) --- 6388 default: 6389 abort (); 6390 break; 6391 } 6392 6393 return type; 6394} 6395 |
6396/* A variable or data member (whose unqualified name is IDENTIFIER) 6397 has been declared with the indicated TYPE. If the TYPE is not 6398 acceptable, issue an error message and return a type to use for 6399 error-recovery purposes. */ 6400 6401tree 6402check_var_type (tree identifier, tree type) 6403{ 6404 if (VOID_TYPE_P (type)) 6405 { 6406 if (!identifier) 6407 error ("unnamed variable or field declared void"); 6408 else if (TREE_CODE (identifier) == IDENTIFIER_NODE) 6409 { 6410 if (IDENTIFIER_OPNAME_P (identifier)) 6411 abort (); 6412 error ("variable or field `%E' declared void", identifier); 6413 } 6414 else 6415 error ("variable or field declared void"); 6416 type = integer_type_node; 6417 } 6418 6419 return type; 6420} 6421 |
|
6320/* Given declspecs and a declarator (abstract or otherwise), determine 6321 the name and type of the object declared and construct a DECL node 6322 for it. 6323 6324 DECLSPECS is a chain of tree_list nodes whose value fields 6325 are the storage classes and type specifiers. 6326 6327 DECL_CONTEXT says which syntactic context this declaration is in: --- 1683 unchanged lines hidden (view full) --- 8011 return type; 8012 } 8013 else if (declarator == NULL_TREE && decl_context != PARM 8014 && decl_context != CATCHPARM 8015 && TREE_CODE (type) != UNION_TYPE 8016 && ! bitfield) 8017 { 8018 error ("abstract declarator `%T' used as declaration", type); | 6422/* Given declspecs and a declarator (abstract or otherwise), determine 6423 the name and type of the object declared and construct a DECL node 6424 for it. 6425 6426 DECLSPECS is a chain of tree_list nodes whose value fields 6427 are the storage classes and type specifiers. 6428 6429 DECL_CONTEXT says which syntactic context this declaration is in: --- 1683 unchanged lines hidden (view full) --- 8113 return type; 8114 } 8115 else if (declarator == NULL_TREE && decl_context != PARM 8116 && decl_context != CATCHPARM 8117 && TREE_CODE (type) != UNION_TYPE 8118 && ! bitfield) 8119 { 8120 error ("abstract declarator `%T' used as declaration", type); |
8019 declarator = make_anon_name (); | 8121 return error_mark_node; |
8020 } 8021 | 8122 } 8123 |
8022 /* `void' at top level (not within pointer) 8023 is allowed only in typedefs or type names. 8024 We don't complain about parms either, but that is because 8025 a better error message can be made later. */ 8026 8027 if (TREE_CODE (type) == VOID_TYPE && decl_context != PARM) | 8124 /* Only functions may be declared using an operator-function-id. */ 8125 if (declarator 8126 && TREE_CODE (declarator) == IDENTIFIER_NODE 8127 && IDENTIFIER_OPNAME_P (declarator) 8128 && TREE_CODE (type) != FUNCTION_TYPE 8129 && TREE_CODE (type) != METHOD_TYPE) |
8028 { | 8130 { |
8029 if (! declarator) 8030 error ("unnamed variable or field declared void"); 8031 else if (TREE_CODE (declarator) == IDENTIFIER_NODE) 8032 { 8033 if (IDENTIFIER_OPNAME_P (declarator)) 8034 abort (); 8035 else 8036 error ("variable or field `%s' declared void", name); 8037 } 8038 else 8039 error ("variable or field declared void"); 8040 type = integer_type_node; | 8131 error ("declaration of `%D' as non-function", declarator); 8132 return error_mark_node; |
8041 } 8042 | 8133 } 8134 |
8135 /* We don't check parameter types here because we can emit a better 8136 error message later. */ 8137 if (decl_context != PARM) 8138 type = check_var_type (declarator, type); 8139 |
|
8043 /* Now create the decl, which may be a VAR_DECL, a PARM_DECL 8044 or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */ 8045 8046 if (decl_context == PARM || decl_context == CATCHPARM) 8047 { 8048 if (ctype || in_namespace) 8049 error ("cannot use `::' in parameter declaration"); 8050 --- 1792 unchanged lines hidden (view full) --- 9843 9844 [dcl.enum] 9845 9846 For an enumeration where emin is the smallest enumerator and emax 9847 is the largest, the values of the enumeration are the values of the 9848 underlying type in the range bmin to bmax, where bmin and bmax are, 9849 respectively, the smallest and largest values of the smallest bit- 9850 field that can store emin and emax. */ | 8140 /* Now create the decl, which may be a VAR_DECL, a PARM_DECL 8141 or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */ 8142 8143 if (decl_context == PARM || decl_context == CATCHPARM) 8144 { 8145 if (ctype || in_namespace) 8146 error ("cannot use `::' in parameter declaration"); 8147 --- 1792 unchanged lines hidden (view full) --- 9940 9941 [dcl.enum] 9942 9943 For an enumeration where emin is the smallest enumerator and emax 9944 is the largest, the values of the enumeration are the values of the 9945 underlying type in the range bmin to bmax, where bmin and bmax are, 9946 respectively, the smallest and largest values of the smallest bit- 9947 field that can store emin and emax. */ |
9851 TYPE_PRECISION (enumtype) = precision; | 9948 9949 /* The middle-end currently assumes that types with TYPE_PRECISION 9950 narrower than their underlying type are suitably zero or sign 9951 extended to fill their mode. g++ doesn't make these guarantees. 9952 Until the middle-end can represent such paradoxical types, we 9953 set the TYPE_PRECISON to the width of the underlying type. */ 9954 TYPE_PRECISION (enumtype) = TYPE_PRECISION (underlying_type); 9955 |
9852 set_min_and_max_values_for_integral_type (enumtype, precision, unsignedp); 9853 9854 /* [dcl.enum] 9855 9856 The value of sizeof() applied to an enumeration type, an object 9857 of an enumeration type, or an enumerator, is the value of sizeof() 9858 applied to the underlying type. */ 9859 TYPE_SIZE (enumtype) = TYPE_SIZE (underlying_type); --- 1387 unchanged lines hidden --- | 9956 set_min_and_max_values_for_integral_type (enumtype, precision, unsignedp); 9957 9958 /* [dcl.enum] 9959 9960 The value of sizeof() applied to an enumeration type, an object 9961 of an enumeration type, or an enumerator, is the value of sizeof() 9962 applied to the underlying type. */ 9963 TYPE_SIZE (enumtype) = TYPE_SIZE (underlying_type); --- 1387 unchanged lines hidden --- |