re PR c++/17816 (duplicate definition of pure virtual function not diagnosed)
authorAlexandre Oliva <aoliva@redhat.com>
Mon, 14 Feb 2005 12:01:15 +0000 (12:01 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Mon, 14 Feb 2005 12:01:15 +0000 (12:01 +0000)
gcc/cp/ChangeLog:
PR c++/17816
* decl.c (redeclaration_error_message): Report redefinition of
pure virtual function.
gcc/testsuite/ChangeLog:
PR c++/17816
* g++.dg/other/redecl2.C: New.

From-SVN: r95008

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

index 7e39ce13ba3080c890ad70700cffa324fdb70afd..777f520179a2380042da55a8769e01e4e2b682bd 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-14  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR c++/17816
+       * decl.c (redeclaration_error_message): Report redefinition of
+       pure virtual function.
+
 2005-02-11  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/19891
index a93cdf8f4c1cac3d100296286dbe197243a55a9b..47732cb6bc8112625dc47632106686704faf7b6a 100644 (file)
@@ -1913,7 +1913,8 @@ redeclaration_error_message (tree newdecl, tree olddecl)
       /* If this is a pure function, its olddecl will actually be
         the original initialization to `0' (which we force to call
         abort()).  Don't complain about redefinition in this case.  */
-      if (DECL_LANG_SPECIFIC (olddecl) && DECL_PURE_VIRTUAL_P (olddecl))
+      if (DECL_LANG_SPECIFIC (olddecl) && DECL_PURE_VIRTUAL_P (olddecl)
+         && DECL_INITIAL (olddecl) == NULL_TREE)
        return 0;
 
       /* If both functions come from different namespaces, this is not
index 78c096320fed27d24f5b7a10a23b5d34b925a720..e185aad254de43fcf7bdebfa53bf474f785d0d5a 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-14  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR c++/17816
+       * g++.dg/other/redecl2.C: New.
+
 2005-02-14  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/19891
diff --git a/gcc/testsuite/g++.dg/other/redecl2.C b/gcc/testsuite/g++.dg/other/redecl2.C
new file mode 100644 (file)
index 0000000..591c258
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/17816
+// We failed to report duplicate definitions of pure virtual ns.
+
+// { dg-do compile }
+
+struct S {
+  virtual int foo() = 0;
+};
+int S::foo() { return 0; } // { dg-error "defined here" }
+int S::foo() { return 0; } // { dg-error "redefinition" }