Commit 55de1b66 by Jakub Jelinek Committed by Jakub Jelinek

decl.c (push_class_binding): Use context_for_name_lookup instead of CP_DECL_CONTEXT.

	* decl.c (push_class_binding): Use context_for_name_lookup instead
	of CP_DECL_CONTEXT.
	* search.c (context_for_name_lookup): Remove static.  Check for NULL
	context in the loop.
	* cp-tree.h (context_for_name_lookup): Add prototype.

	* g++.old-deja/g++.other/anon6.C: New test.
	* g++.old-deja/g++.other/anon7.C: New test.

From-SVN: r39417
parent 2bf9b27d
2001-02-03 Jakub Jelinek <jakub@redhat.com>
* decl.c (push_class_binding): Use context_for_name_lookup instead
of CP_DECL_CONTEXT.
* search.c (context_for_name_lookup): Remove static. Check for NULL
context in the loop.
* cp-tree.h (context_for_name_lookup): Add prototype.
2001-02-02 Jakub Jelinek <jakub@redhat.com>
* cp-tree.h (build_expr_ptr_wrapper, can_free): Remove.
......
......@@ -4211,6 +4211,7 @@ extern void init_search_processing PARAMS ((void));
extern void reinit_search_statistics PARAMS ((void));
extern tree current_scope PARAMS ((void));
extern int at_function_scope_p PARAMS ((void));
extern tree context_for_name_lookup PARAMS ((tree));
extern tree lookup_conversions PARAMS ((tree));
extern tree binfo_for_vtable PARAMS ((tree));
extern tree binfo_from_vbase PARAMS ((tree));
......
......@@ -1124,7 +1124,7 @@ push_class_binding (id, decl)
else
{
my_friendly_assert (DECL_P (decl), 0);
context = CP_DECL_CONTEXT (decl);
context = context_for_name_lookup (decl);
}
if (is_properly_derived_from (current_class_type, context))
......
......@@ -120,7 +120,6 @@ static tree bfs_walk
void *));
static tree lookup_field_queue_p PARAMS ((tree, void *));
static tree lookup_field_r PARAMS ((tree, void *));
static tree context_for_name_lookup PARAMS ((tree));
static tree canonical_binfo PARAMS ((tree));
static tree shared_marked_p PARAMS ((tree, void *));
static tree shared_unmarked_p PARAMS ((tree, void *));
......@@ -714,7 +713,7 @@ at_function_scope_p ()
/* Return the scope of DECL, as appropriate when doing name-lookup. */
static tree
tree
context_for_name_lookup (decl)
tree decl;
{
......@@ -724,9 +723,9 @@ context_for_name_lookup (decl)
definition, the members of the anonymous union are considered to
have been defined in the scope in which the anonymous union is
declared. */
tree context = CP_DECL_CONTEXT (decl);
tree context = DECL_CONTEXT (decl);
while (TYPE_P (context) && ANON_AGGR_TYPE_P (context))
while (context && TYPE_P (context) && ANON_AGGR_TYPE_P (context))
context = TYPE_CONTEXT (context);
if (!context)
context = global_namespace;
......
2001-02-03 Jakub Jelinek <jakub@redhat.com>
* g++.old-deja/g++.other/anon6.C: New test.
* g++.old-deja/g++.other/anon7.C: New test.
2001-02-01 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/cpp/avoidpaste2.c: New tests.
......
extern "C" void abort ();
struct A {
union {
int a;
double b;
int d;
};
int c;
};
struct B : public A {
union {
double a;
void *c;
};
float b;
int e;
};
int main ()
{
struct B b;
b.a = 1.5;
b.b = 2.5;
b.d = 1;
b.e = 2;
if (b.a != 1.5 || b.b != 2.5 || b.d != 1 || b.e != 2)
abort ();
b.c = &b.a;
b.d = b.e;
if (b.c != &b.a || b.d != 2)
abort ();
return 0;
}
// Build don't link:
struct A {
union {
int a; // ERROR - conflicts with previous declaration
};
int a; // ERROR -
};
struct B {
int b; // ERROR - conflicts with previous declaration
union {
int b; // ERROR - duplicate member
}; // ERROR - declaration of
};
struct C {
union {
int c; // ERROR - conflicts with previous declaration
};
union {
int c; // ERROR - duplicate member
}; // ERROR - declaration of
};
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