aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-07-14 13:01:03 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-07-14 13:01:03 -0400
commit535335bffc08ebcfbabfd8f1bbff2fa6d5f0e429 (patch)
tree7e0d15d22f642156e721ae21c33d2dc89e38117a /gcc/cp/init.c
parent57ece2583335d663e2787df4f6fe3804ec921ea9 (diff)
downloadgcc-535335bffc08ebcfbabfd8f1bbff2fa6d5f0e429.zip
gcc-535335bffc08ebcfbabfd8f1bbff2fa6d5f0e429.tar.gz
gcc-535335bffc08ebcfbabfd8f1bbff2fa6d5f0e429.tar.bz2
init.c (sort_mem_initializers): Rename "field_type" to "ctx".
* init.c (sort_mem_initializers): Rename "field_type" to "ctx". (build_field_list): Cache field type. From-SVN: r162188
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 4e7cab3..98a45cd 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -564,25 +564,27 @@ build_field_list (tree t, tree list, int *uses_unions_p)
for (fields = TYPE_FIELDS (t); fields; fields = TREE_CHAIN (fields))
{
+ tree fieldtype;
+
/* Skip CONST_DECLs for enumeration constants and so forth. */
if (TREE_CODE (fields) != FIELD_DECL || DECL_ARTIFICIAL (fields))
continue;
+ fieldtype = TREE_TYPE (fields);
/* Keep track of whether or not any fields are unions. */
- if (TREE_CODE (TREE_TYPE (fields)) == UNION_TYPE)
+ if (TREE_CODE (fieldtype) == UNION_TYPE)
*uses_unions_p = 1;
/* For an anonymous struct or union, we must recursively
consider the fields of the anonymous type. They can be
directly initialized from the constructor. */
- if (ANON_AGGR_TYPE_P (TREE_TYPE (fields)))
+ if (ANON_AGGR_TYPE_P (fieldtype))
{
/* Add this field itself. Synthesized copy constructors
initialize the entire aggregate. */
list = tree_cons (fields, NULL_TREE, list);
/* And now add the fields in the anonymous aggregate. */
- list = build_field_list (TREE_TYPE (fields), list,
- uses_unions_p);
+ list = build_field_list (fieldtype, list, uses_unions_p);
}
/* Add this field. */
else if (DECL_NAME (fields))
@@ -718,7 +720,7 @@ sort_mem_initializers (tree t, tree mem_inits)
for (p = &sorted_inits; *p; )
{
tree field;
- tree field_type;
+ tree ctx;
int done;
init = *p;
@@ -736,13 +738,13 @@ sort_mem_initializers (tree t, tree mem_inits)
/* See if this field is a member of a union, or a member of a
structure contained in a union, etc. */
- for (field_type = DECL_CONTEXT (field);
- !same_type_p (field_type, t);
- field_type = TYPE_CONTEXT (field_type))
- if (TREE_CODE (field_type) == UNION_TYPE)
+ for (ctx = DECL_CONTEXT (field);
+ !same_type_p (ctx, t);
+ ctx = TYPE_CONTEXT (ctx))
+ if (TREE_CODE (ctx) == UNION_TYPE)
break;
/* If this field is not a member of a union, skip it. */
- if (TREE_CODE (field_type) != UNION_TYPE)
+ if (TREE_CODE (ctx) != UNION_TYPE)
goto next;
/* If this union member has no explicit initializer, splice
@@ -766,37 +768,37 @@ sort_mem_initializers (tree t, tree mem_inits)
union { struct { int i; int j; }; };
initializing both `i' and `j' makes sense. */
- field_type = DECL_CONTEXT (field);
+ ctx = DECL_CONTEXT (field);
done = 0;
do
{
- tree last_field_type;
+ tree last_ctx;
- last_field_type = DECL_CONTEXT (last_field);
+ last_ctx = DECL_CONTEXT (last_field);
while (1)
{
- if (same_type_p (last_field_type, field_type))
+ if (same_type_p (last_ctx, ctx))
{
- if (TREE_CODE (field_type) == UNION_TYPE)
+ if (TREE_CODE (ctx) == UNION_TYPE)
error_at (DECL_SOURCE_LOCATION (current_function_decl),
"initializations for multiple members of %qT",
- last_field_type);
+ last_ctx);
done = 1;
break;
}
- if (same_type_p (last_field_type, t))
+ if (same_type_p (last_ctx, t))
break;
- last_field_type = TYPE_CONTEXT (last_field_type);
+ last_ctx = TYPE_CONTEXT (last_ctx);
}
/* If we've reached the outermost class, then we're
done. */
- if (same_type_p (field_type, t))
+ if (same_type_p (ctx, t))
break;
- field_type = TYPE_CONTEXT (field_type);
+ ctx = TYPE_CONTEXT (ctx);
}
while (!done);