From 1221bff1f517d7f0453f4c3bffaa9493afce3ab7 Mon Sep 17 00:00:00 2001
From: aaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 22 May 2007 21:05:01 +0000
Subject: [PATCH] 	* name-lookup.c (ambiguous_decl): Adds check for
 hidden types. 	(unqualified_namespace_lookup): Adds check for hidden types.

	* g++.dg/lookup/hidden-class10.C: New test.
	* g++.dg/lookup/hidden-class11.C: New test.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124963 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/cp/ChangeLog                             |  5 +++++
 gcc/cp/name-lookup.c                         |  6 +++--
 gcc/testsuite/ChangeLog                      |  5 +++++
 gcc/testsuite/g++.dg/lookup/hidden-class10.C | 11 ++++++++++
 gcc/testsuite/g++.dg/lookup/hidden-class11.C | 23 ++++++++++++++++++++
 5 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/lookup/hidden-class10.C
 create mode 100644 gcc/testsuite/g++.dg/lookup/hidden-class11.C

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7fc9a0707535..df07249a0dd5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2007-05-22  Ollie Wild  <aaw@google.com>
+
+	* name-lookup.c (ambiguous_decl): Adds check for hidden types.
+	(unqualified_namespace_lookup): Adds check for hidden types.
+
 2007-05-22  Ollie Wild  <aaw@google.com>
 
 	* decl.c (duplicate_decls): Verify namespace names are unique.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index a7a12cd4b3a8..befc2d3a037e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3543,7 +3543,7 @@ ambiguous_decl (tree name, struct scope_binding *old, cxx_binding *new,
     }
   /* ... and copy the type.  */
   type = new->type;
-  if (LOOKUP_NAMESPACES_ONLY (flags))
+  if (LOOKUP_NAMESPACES_ONLY (flags) || (type && hidden_name_p (type)))
     type = NULL_TREE;
   if (!old->type)
     old->type = type;
@@ -3699,7 +3699,9 @@ unqualified_namespace_lookup (tree name, int flags)
 	  if (b->value
 	      && ((flags & LOOKUP_HIDDEN) || !hidden_name_p (b->value)))
 	    binding.value = b->value;
-	  binding.type = b->type;
+	  if (b->type
+	      && ((flags & LOOKUP_HIDDEN) || !hidden_name_p (b->type)))
+	    binding.type = b->type;
 	}
 
       /* Add all _DECLs seen through local using-directives.  */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 77b6a7fa3260..189d5ff9ea49 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-05-22  Ollie Wild  <aaw@google.com>
+
+	* g++.dg/lookup/hidden-class10.C: New test.
+	* g++.dg/lookup/hidden-class11.C: New test.
+
 2007-05-22  Ollie Wild  <aaw@google.com>
 
 	* g++.dg/lookup/name-clash5.C: New test.
diff --git a/gcc/testsuite/g++.dg/lookup/hidden-class10.C b/gcc/testsuite/g++.dg/lookup/hidden-class10.C
new file mode 100644
index 000000000000..f68196ff8a1d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/hidden-class10.C
@@ -0,0 +1,11 @@
+// Copyright (C) 2007 Free Software Foundation
+// Contributed by Ollie Wild <aaw@google.com>
+// { dg-do compile }
+
+// Verify that a friend class is hidden even if it overrides a builtin
+// function name.
+
+class A {
+  friend class abort;
+  abort *b;	// { dg-error "no type|expected" }
+};
diff --git a/gcc/testsuite/g++.dg/lookup/hidden-class11.C b/gcc/testsuite/g++.dg/lookup/hidden-class11.C
new file mode 100644
index 000000000000..8432e32d85a0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/hidden-class11.C
@@ -0,0 +1,23 @@
+// Copyright (C) 2007 Free Software Foundation
+// Contributed by Ollie Wild <aaw@google.com>
+// { dg-do compile }
+
+// Verify that a friend class is hidden even if it is hidden by a non-builtin
+// function name.
+
+namespace M {
+  void F (void);
+  class F;
+}
+
+namespace N {
+  void F(void);
+  class A {
+    friend class F;
+  };
+}
+
+using namespace M;
+using namespace N;
+
+class F *b;
-- 
GitLab