Commit 75135253 by Mark Mitchell Committed by Mark Mitchell

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
parent d4be2966
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
2003-04-29 Mark Mitchell <mark@codesourcery.com> 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 * decl.c (maybe_commonize_var): Further tweak support for systems
without weak symbols. without weak symbols.
......
...@@ -4014,6 +4014,7 @@ extern int types_overlap_p (tree, tree); ...@@ -4014,6 +4014,7 @@ extern int types_overlap_p (tree, tree);
extern tree get_vbase (tree, tree); extern tree get_vbase (tree, tree);
extern tree get_dynamic_cast_base_type (tree, tree); extern tree get_dynamic_cast_base_type (tree, tree);
extern int accessible_p (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 tree lookup_field (tree, tree, int, bool);
extern int lookup_fnfields_1 (tree, tree); extern int lookup_fnfields_1 (tree, tree);
extern tree lookup_fnfields (tree, tree, int); extern tree lookup_fnfields (tree, tree, int);
......
...@@ -81,7 +81,6 @@ struct vbase_info ...@@ -81,7 +81,6 @@ struct vbase_info
tree inits; tree inits;
}; };
static tree lookup_field_1 (tree, tree, bool);
static tree dfs_check_overlap (tree, void *); static tree dfs_check_overlap (tree, void *);
static tree dfs_no_overlap_yet (tree, int, void *); static tree dfs_no_overlap_yet (tree, int, void *);
static base_kind lookup_base_r (tree, tree, base_access, static base_kind lookup_base_r (tree, tree, base_access,
...@@ -430,7 +429,7 @@ get_dynamic_cast_base_type (tree subtype, tree target) ...@@ -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 figure out whether it can access this field. (Since it is only one
level, this is reasonable.) */ level, this is reasonable.) */
static tree tree
lookup_field_1 (tree type, tree name, bool want_type) lookup_field_1 (tree type, tree name, bool want_type)
{ {
register tree field; register tree field;
......
2003-04-29 Mark Mitchell <mark@codesourcery.com> 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. * g++.old-deja/g++.pt/deduct5.C: Remove unnecessary initializer.
2003-04-28 Mark Mitchell <mark@codesourcery.com> 2003-04-28 Mark Mitchell <mark@codesourcery.com>
......
// { 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;
}
// PR c++/9623 // PR c++/9623
// Test for trivial use of named initializer extension // Test for trivial use of named initializer extension
// { dg-options "" }
struct S { int x; int y; }; struct S { int x; int y; };
S s = { x:1, y:2 }; S s = { x:1, y: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