Commit ff9f1a5d by Mark Mitchell Committed by Mark Mitchell

decl2.c (finish_anon_union): Generalize error messages to handle anonymous structures.

	* decl2.c (finish_anon_union): Generalize error messages to handle
	anonymous structures.
	* init.c (perform_member_init): Remove `name' parameter.
	(build_field_list): New function.
	(sort_member_init): Handle anonymous union initialization order
	correctly.  Check for multiple initializations of the same union.
	(emit_base_init): Don't look up fields by name here.
	(expand_member_init): Record the result of name lookup for future
	reference.
	* typeck.c (build_component_ref): Fix formatting.

From-SVN: r33963
parent 2c0b35cb
2000-05-17 Mark Mitchell <mark@codesourcery.com>
* decl2.c (finish_anon_union): Generalize error messages to handle
anonymous structures.
* init.c (perform_member_init): Remove `name' parameter.
(build_field_list): New function.
(sort_member_init): Handle anonymous union initialization order
correctly. Check for multiple initializations of the same union.
(emit_base_init): Don't look up fields by name here.
(expand_member_init): Record the result of name lookup for future
reference.
* typeck.c (build_component_ref): Fix formatting.
Wed May 17 17:27:44 2000 Andrew Cagney <cagney@b1.cygnus.com>
* decl.c (pop_label): Replace warn_unused with warn_unused_label.
......
......@@ -2172,7 +2172,7 @@ finish_anon_union (anon_union_decl)
if (public_p)
{
error ("global anonymous unions must be declared static");
error ("namespace-scope anonymous aggregates must be static");
return;
}
......@@ -2182,7 +2182,7 @@ finish_anon_union (anon_union_decl)
if (main_decl == NULL_TREE)
{
warning ("anonymous union with no members");
warning ("anonymous aggregate with no members");
return;
}
......
......@@ -2189,9 +2189,7 @@ build_component_ref (datum, component, basetype_path, protect)
tree base = context;
while (!same_type_p (base, basetype) && TYPE_NAME (base)
&& ANON_AGGR_TYPE_P (base))
{
base = TYPE_CONTEXT (base);
}
base = TYPE_CONTEXT (base);
/* Handle base classes here... */
if (base != basetype && TYPE_BASE_CONVS_MAY_REQUIRE_CODE_P (basetype))
......
// Origin: Mark Mitchell <mark@codesourcery.com>
struct A
{
union
{
int i;
};
int j;
A ();
};
A::A ()
: i (1), j (i = 0)
{
}
int main ()
{
A a;
return a.i;
}
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
// Special g++ Options:
union A
{
int i;
int j;
A () : i (3), j (2) {} // ERROR - multiple initializations
};
union B
{
int i;
union {
int j;
};
B () : i (3), j (2) {} // ERROR - multiple initializations
};
union C
{
union {
struct {
int i;
int j;
};
};
C () : i (3), j (2) {}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment