public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] c++: Emit as-base 'tor symbols for final class. [PR95428]
@ 2020-08-28 16:01 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-08-28 16:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6b958ee0fd0e1b2a2b22784ffbe531ed74358a22

commit 6b958ee0fd0e1b2a2b22784ffbe531ed74358a22
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Aug 21 16:23:03 2020 -0400

    c++: Emit as-base 'tor symbols for final class.  [PR95428]
    
    For PR70462 I stopped emitting the as-base constructor and destructor
    variants for final classes, because they can never be called.  Except that
    it turns out that clang calls base variants from complete variants, even for
    classes with virtual bases, and in some cases inlines them such that the
    calls to the base variant are exposed.  So we need to continue to emit the
    as-base symbols, even though they're unreachable by G++-compiled code.
    
    gcc/cp/ChangeLog:
    
            PR c++/95428
            * optimize.c (populate_clone_array): Revert PR70462 change.
            (maybe_clone_body): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/other/final8.C: Adjust expected output.

Diff:
---
 gcc/cp/optimize.c                   | 10 ++--------
 gcc/testsuite/g++.dg/other/final8.C |  8 ++++++--
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index abdcd7fa19f..00621d636bf 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -244,19 +244,13 @@ populate_clone_array (tree fn, tree *fns)
   fns[1] = NULL_TREE;
   fns[2] = NULL_TREE;
 
-  tree ctx = DECL_CONTEXT (fn);
-
   FOR_EACH_CLONE (clone, fn)
     if (DECL_NAME (clone) == complete_dtor_identifier
 	|| DECL_NAME (clone) == complete_ctor_identifier)
       fns[1] = clone;
     else if (DECL_NAME (clone) == base_dtor_identifier
 	     || DECL_NAME (clone) == base_ctor_identifier)
-      {
-	/* We don't need to define the base variants for a final class.  */
-	if (!CLASSTYPE_FINAL (ctx))
-	  fns[0] = clone;
-      }
+      fns[0] = clone;
     else if (DECL_NAME (clone) == deleting_dtor_identifier)
       fns[2] = clone;
     else
@@ -481,7 +475,7 @@ maybe_clone_body (tree fn)
 
   /* Remember if we can't have multiple clones for some reason.  We need to
      check this before we remap local static initializers in clone_body.  */
-  if (!tree_versionable_function_p (fn) && fns[0] && fns[1])
+  if (!tree_versionable_function_p (fn))
     need_alias = true;
 
   /* We know that any clones immediately follow FN in the TYPE_FIELDS
diff --git a/gcc/testsuite/g++.dg/other/final8.C b/gcc/testsuite/g++.dg/other/final8.C
index f90f94e9ea0..67c87112353 100644
--- a/gcc/testsuite/g++.dg/other/final8.C
+++ b/gcc/testsuite/g++.dg/other/final8.C
@@ -1,6 +1,10 @@
+// PR c++/70462
+// PR c++/95428
 // { dg-do compile { target c++11 } }
-// { dg-final { scan-assembler-not "_ZN1BC2Ev" } }
-// { dg-final { scan-assembler-not "_ZN1BD2Ev" } }
+// { dg-final { scan-assembler "_ZN1BC1Ev" } }
+// { dg-final { scan-assembler "_ZN1BC2Ev" } }
+// { dg-final { scan-assembler "_ZN1BD2Ev" } }
+// { dg-final { scan-assembler "_ZN1BD1Ev" } }
 
 struct A { int i; A(); virtual ~A() = 0; };
 struct B final: public virtual A { int j; B(); ~B(); };


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-28 16:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 16:01 [gcc/devel/c++-modules] c++: Emit as-base 'tor symbols for final class. [PR95428] Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).