OSDN Git Service

PR c++/9970
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Mar 2003 14:30:18 +0000 (14:30 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 9 Mar 2003 14:30:18 +0000 (14:30 +0000)
* decl.c (duplicate_decls): Only copy DECL_THUNKS for virtual
functions.

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

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

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

index d1538bc..7d7debe 100644 (file)
@@ -1,3 +1,9 @@
+2003-03-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/9970
+       * decl.c (duplicate_decls): Only copy DECL_THUNKS for virtual
+       functions.
+
 2003-03-08  Geoffrey Keating  <geoffk@apple.com>
 
        * lang-specs.h (c++-header): Change .pch to .gch.
index fb36313..639c5d0 100644 (file)
@@ -3554,7 +3554,10 @@ duplicate_decls (tree newdecl, tree olddecl)
          DECL_BEFRIENDING_CLASSES (newdecl)
            = chainon (DECL_BEFRIENDING_CLASSES (newdecl),
                       DECL_BEFRIENDING_CLASSES (olddecl));
-         DECL_THUNKS (newdecl) = DECL_THUNKS (olddecl);
+         /* DECL_THUNKS is only valid for virtual functions,
+            otherwise it is a DECL_FRIEND_CONTEXT.  */
+         if (DECL_VIRTUAL_P (newdecl))
+           DECL_THUNKS (newdecl) = DECL_THUNKS (olddecl);
        }
     }
 
index 8c11f85..15d6935 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/9970
+       * g++.dg/lookup/friend1.C: New test.
+
 2003-03-08  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/9823
diff --git a/gcc/testsuite/g++.dg/lookup/friend1.C b/gcc/testsuite/g++.dg/lookup/friend1.C
new file mode 100644 (file)
index 0000000..47fe055
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+
+// Origin: <matz@suse.de>
+
+// PR c++/9970: In-class friend function definition after
+// declaration lexical scope problem.
+
+void f();
+struct X
+{
+  enum { k = 1 };
+  friend void f() {
+        char a[k];
+  }
+};