+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.
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));
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))
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 *));
/* Return the scope of DECL, as appropriate when doing name-lookup. */
-static tree
+tree
context_for_name_lookup (decl)
tree 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.
--- /dev/null
+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;
+}
--- /dev/null
+// 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
+};