re PR c++/10515 (problem when initializing a field in a union)

PR c++/10515
	* g++.dg/ext/desig1.C: New test.
	* g++.dg/ext/init1.C: Likewise.

	PR c++/10515
	* cp-tree.h (lookup_field_1): Declare it.
	* search.c (lookup_field_1): Make it public.
	* decl.c (reshape_init): Handle designated initializers.

From-SVN: r66235
This commit is contained in:
Mark Mitchell 2003-04-29 18:00:23 +00:00 committed by Mark Mitchell
parent d4be2966f3
commit 7513525363
6 changed files with 35 additions and 2 deletions

View File

@ -5,6 +5,11 @@
2003-04-29 Mark Mitchell <mark@codesourcery.com>
PR c++/10515
* cp-tree.h (lookup_field_1): Declare it.
* search.c (lookup_field_1): Make it public.
* decl.c (reshape_init): Handle designated initializers.
* decl.c (maybe_commonize_var): Further tweak support for systems
without weak symbols.

View File

@ -4014,6 +4014,7 @@ extern int types_overlap_p (tree, tree);
extern tree get_vbase (tree, tree);
extern tree get_dynamic_cast_base_type (tree, tree);
extern int accessible_p (tree, tree);
extern tree lookup_field_1 (tree, tree, bool);
extern tree lookup_field (tree, tree, int, bool);
extern int lookup_fnfields_1 (tree, tree);
extern tree lookup_fnfields (tree, tree, int);

View File

@ -81,7 +81,6 @@ struct vbase_info
tree inits;
};
static tree lookup_field_1 (tree, tree, bool);
static tree dfs_check_overlap (tree, void *);
static tree dfs_no_overlap_yet (tree, int, void *);
static base_kind lookup_base_r (tree, tree, base_access,
@ -430,7 +429,7 @@ get_dynamic_cast_base_type (tree subtype, tree target)
figure out whether it can access this field. (Since it is only one
level, this is reasonable.) */
static tree
tree
lookup_field_1 (tree type, tree name, bool want_type)
{
register tree field;

View File

@ -1,5 +1,8 @@
2003-04-29 Mark Mitchell <mark@codesourcery.com>
* g++.dg/ext/desig1.C: New test.
* g++.dg/ext/init1.C: Likewise.
* g++.old-deja/g++.pt/deduct5.C: Remove unnecessary initializer.
2003-04-28 Mark Mitchell <mark@codesourcery.com>

View File

@ -0,0 +1,24 @@
// { dg-options "" }
struct a {
int x;
};
struct b {
int x;
int y;
};
struct foo {
union {
struct a a;
struct b b;
} u;
};
int main(void)
{
struct foo bar = { u: { b: { x: 0, y: 0, }}};
(void)bar;
return 0;
}

View File

@ -1,5 +1,6 @@
// PR c++/9623
// Test for trivial use of named initializer extension
// { dg-options "" }
struct S { int x; int y; };
S s = { x:1, y:2 };