OSDN Git Service

PR c++/19258
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Jan 2005 15:41:34 +0000 (15:41 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Jan 2005 15:41:34 +0000 (15:41 +0000)
* pt.c (push_access_scope): Handle friend defined in class.
(pop_access_scope): Likewise.

* g++.dg/lookup/friend6.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92993 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/friend6.C [new file with mode: 0644]

index fb98595..628d046 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/19258
+       * pt.c (push_access_scope): Handle friend defined in class.
+       (pop_access_scope): Likewise.
+
 2005-01-06  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/19270
index e6f4b51..ad852c5 100644 (file)
@@ -176,7 +176,9 @@ push_access_scope (tree t)
   gcc_assert (TREE_CODE (t) == FUNCTION_DECL
              || TREE_CODE (t) == VAR_DECL);
 
-  if (DECL_CLASS_SCOPE_P (t))
+  if (DECL_FRIEND_CONTEXT (t))
+    push_nested_class (DECL_FRIEND_CONTEXT (t));
+  else if (DECL_CLASS_SCOPE_P (t))
     push_nested_class (DECL_CONTEXT (t));
   else
     push_to_top_level ();
@@ -201,7 +203,7 @@ pop_access_scope (tree t)
       saved_access_scope = TREE_CHAIN (saved_access_scope);
     }
 
-  if (DECL_CLASS_SCOPE_P (t))
+  if (DECL_FRIEND_CONTEXT (t) || DECL_CLASS_SCOPE_P (t))
     pop_nested_class ();
   else
     pop_from_top_level ();
index 139d695..8ed16ad 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-06  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/19258
+       * g++.dg/lookup/friend6.C: New test.
+
 2005-01-06  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/19270
diff --git a/gcc/testsuite/g++.dg/lookup/friend6.C b/gcc/testsuite/g++.dg/lookup/friend6.C
new file mode 100644 (file)
index 0000000..e3dafb1
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+
+// Origin: Matt Austern <austern@apple.com>
+
+// PR c++/19258: Wrong lookup scope for friend defined in class.
+
+class X {
+  template<class T> friend int ff(T*, int y=anX.x) { return y; }
+  int f() { return ff(&anX); }
+
+  static X anX;
+  int x;
+};
+
+X dummy;