re PR c++/4476 (g++ does not parse the definition of friend function within a class...
authorNathan Sidwell <nathan@codesourcery.com>
Fri, 12 Oct 2001 09:06:32 +0000 (09:06 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 12 Oct 2001 09:06:32 +0000 (09:06 +0000)
cp:
PR g++/4476
* typeck2.c (abstract_virtuals_error): Ignore incomplete classes.
testsuite:
PR g++/4476
* g++.dg/other/friend1.C: New test.

From-SVN: r46226

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

index 4c4cdce311aef185a8070eab5189bb35f9c72799..50af8393877a87d8c1be0fa1a7be03bfef06d2ff 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-12  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR g++/4476
+       * typeck2.c (abstract_virtuals_error): Ignore incomplete classes.
+
 2001-10-11  Jason Merrill  <jason_merrill@redhat.com>
 
        * typeck2.c (store_init_value): Don't re-digest a bracketed
index fbedc13426a325f2a0171ec927d83996cf7b6d7b..2a9b2a917949fdaa621f983e78fd66f9e134c264 100644 (file)
@@ -140,6 +140,11 @@ abstract_virtuals_error (decl, type)
   if (!CLASS_TYPE_P (type) || !CLASSTYPE_PURE_VIRTUALS (type))
     return 0;
 
+  if (!TYPE_SIZE (type))
+    /* TYPE is being defined, and during that time
+       CLASSTYPE_PURE_VIRTUALS holds the inline friends.  */
+    return 0;
+
   u = CLASSTYPE_PURE_VIRTUALS (type);
   if (decl)
     {
index d7fd68e6291f65e39f22b4ed13989c300ce086f4..2a50b83736d857749498da7602d4ebf0b7276bc4 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-12  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR g++/4476
+       * g++.dg/other/friend1.C: New test.
+
 2001-10-11  Richard Henderson  <rth@redhat.com>
 
        * g++.old-deja/g++.other/crash18.C: Add -S to options.
diff --git a/gcc/testsuite/g++.dg/other/friend1.C b/gcc/testsuite/g++.dg/other/friend1.C
new file mode 100644 (file)
index 0000000..3193180
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 10 Oct 2001 <nathan@codesourcery.com>
+
+// Bug 4476. We tangled up inline friends and pure virtuals during
+// class definition.
+
+struct A {
+  friend void f () { }
+  void g (A a) {  }
+};