]> gcc.gnu.org Git - gcc.git/commitdiff
decl.c (push_class_binding): Use context_for_name_lookup instead of CP_DECL_CONTEXT.
authorJakub Jelinek <jakub@redhat.com>
Sat, 3 Feb 2001 00:27:28 +0000 (01:27 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 3 Feb 2001 00:27:28 +0000 (01:27 +0100)
* 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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/anon6.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.other/anon7.C [new file with mode: 0644]

index edb2039938afdb35a2b73cc48701d00b9e6629b9..b9d81e1daa5c858a53e39c419223dd2be54012dc 100644 (file)
@@ -1,3 +1,11 @@
+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.
index 3ec2778f08c9a08a42b1dad5539a4248e329de3c..60421a391b6fbc69b57c69d86858d16584de55e2 100644 (file)
@@ -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));
index 080853e37c13f20001a7616e2eeed359cb681ba7..44a3b3b947d54e27e40a5ce1c52696c975d1cdbc 100644 (file)
@@ -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))
index 0bb309fa5bded80bc36d69bc428d2259282e1813..c8cf526035f3a4e21d616a00f18653df3f3880a9 100644 (file)
@@ -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;
index c00497e1588eb799202e675cb4a763b5d2c4aa64..60daf5689466c4bc4e272f70087c4a4d4c083315 100644 (file)
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon6.C b/gcc/testsuite/g++.old-deja/g++.other/anon6.C
new file mode 100644 (file)
index 0000000..4fd9e7d
--- /dev/null
@@ -0,0 +1,36 @@
+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;
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/anon7.C b/gcc/testsuite/g++.old-deja/g++.other/anon7.C
new file mode 100644 (file)
index 0000000..ba624a0
--- /dev/null
@@ -0,0 +1,24 @@
+// 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
+};
This page took 0.141987 seconds and 5 git commands to generate.