re PR c++/90909 (call devirtualized to pure virtual)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 21 Jun 2019 20:46:51 +0000 (20:46 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 21 Jun 2019 20:46:51 +0000 (20:46 +0000)
/cp
2019-06-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/90909
Revert:
2019-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/67184
PR c++/69445
* call.c (build_over_call): Devirtualize when the final overrider
comes from the base.

/testsuite
2019-06-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/90909
Revert:
2019-05-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/67184
PR c++/69445
* g++.dg/other/final3.C: New.
* g++.dg/other/final4.C: Likewise.
* g++.dg/other/final5.C: Likewise.

* g++.dg/other/final6.C: New.

From-SVN: r272573

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

index 9b7529514733ef21c1f1df4ba734ffc0e3c49ded..4d454b6f9f9b01c1e007bf17118229a58a8c95ae 100644 (file)
@@ -1,3 +1,14 @@
+2019-06-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/90909
+       Revert:
+       2019-05-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/67184
+       PR c++/69445
+       * call.c (build_over_call): Devirtualize when the final overrider
+       comes from the base.
+
 2019-06-21  Marek Polacek  <polacek@redhat.com>
 
        PR c++/61490 - qualified-id in friend function definition.
index c04ca2ee7ce63a177ecf697c743390d028619c68..8367ef7b557026b49b44c615ca85dc474502758a 100644 (file)
@@ -8244,7 +8244,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
       /* See if the function member or the whole class type is declared
         final and the call can be devirtualized.  */
       if (DECL_FINAL_P (fn)
-         || CLASSTYPE_FINAL (TREE_TYPE (argtype)))
+         || CLASSTYPE_FINAL (TYPE_METHOD_BASETYPE (TREE_TYPE (fn))))
        flags |= LOOKUP_NONVIRTUAL;
 
       /* [class.mfct.nonstatic]: If a nonstatic member function of a class
index d5367b203c426f29bb977d387fc6c935adf790ca..14ef07cd1a96429e976db9db35d8a658005607d1 100644 (file)
@@ -1,3 +1,17 @@
+2019-06-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/90909
+       Revert:
+       2019-05-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/67184
+       PR c++/69445
+       * g++.dg/other/final3.C: New.
+       * g++.dg/other/final4.C: Likewise.
+       * g++.dg/other/final5.C: Likewise.
+
+       * g++.dg/other/final6.C: New.
+
 2019-06-21  Marek Polacek  <polacek@redhat.com>
 
        PR c++/61490 - qualified-id in friend function definition.
diff --git a/gcc/testsuite/g++.dg/other/final6.C b/gcc/testsuite/g++.dg/other/final6.C
new file mode 100644 (file)
index 0000000..1979038
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/90909
+// { dg-do link { target c++11 } }
+
+struct S1 { virtual void f() = 0; };
+struct S2: S1 { virtual void f() {} };
+struct S3: S2 { using S1::f; };
+struct S4 final: S3 { void g(); };
+void S4::g() { f(); }
+int main() { S4().g(); }