summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-03 00:27:28 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2001-02-03 00:27:28 +0000
commitbf3e930356f8fd4cce29ad521b34e59bfd3c526b (patch)
treef3d31f5162151f6fcae8bb32cda44e06be229762 /gcc
parent3acdc02b5f29d6df52cb3b1b153e8f44eb60ca4f (diff)
downloadppe42-gcc-bf3e930356f8fd4cce29ad521b34e59bfd3c526b.tar.gz
ppe42-gcc-bf3e930356f8fd4cce29ad521b34e59bfd3c526b.zip
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39417 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/search.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/anon6.C36
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/anon7.C24
7 files changed, 78 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index edb2039938a..b9d81e1daa5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3ec2778f08c..60421a391b6 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 080853e37c1..44a3b3b947d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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))
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 0bb309fa5bd..c8cf526035f 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c00497e1588..60daf568946 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..4fd9e7d52fc
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/anon6.C
@@ -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
index 00000000000..ba624a059b5
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/anon7.C
@@ -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
+};
OpenPOWER on IntegriCloud