diff mbox series

[Ada] Fix wrong translation of C++ virtual destructor

Message ID 8888127.YASx4lQ5Rx@polaris
State New
Headers show
Series [Ada] Fix wrong translation of C++ virtual destructor | expand

Commit Message

Eric Botcazou April 9, 2019, 7:27 p.m. UTC
This is a regression present on all active branches: -fdump-ada-spec no longer 
generates a declaration for the (implicit) deleting destructor in a class, 
which is problematic if it's virtual because it has a slot in the vtable.

Tested on x86_64-suse-linux, applied on all active branches.


2019-04-09  Eric Botcazou  <ebotcazou@adacore.com>

c-family/
	* c-ada-spec.c (print_destructor): Deal with deleting destructors.
	(dump_ada_declaration) <FUNCTION_DECL>: Likewise.
diff mbox series

Patch

Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c	(revision 270188)
+++ c-ada-spec.c	(working copy)
@@ -2676,6 +2676,8 @@  print_destructor (pretty_printer *buffer
   tree decl_name = DECL_NAME (TYPE_NAME (type));
 
   pp_string (buffer, "Delete_");
+  if (strncmp (IDENTIFIER_POINTER (DECL_NAME (t)), "__dt_del", 8) == 0)
+    pp_string (buffer, "And_Free_");
   pp_ada_tree_identifier (buffer, decl_name, t, false);
 }
 
@@ -2946,9 +2948,10 @@  dump_ada_declaration (pretty_printer *bu
 	  if (DECL_ARTIFICIAL (t))
 	    return 0;
 
-	  /* Only consider constructors/destructors for complete objects.  */
+	  /* Only consider complete constructors and deleting destructors.  */
 	  if (strncmp (IDENTIFIER_POINTER (decl_name), "__ct_comp", 9) != 0
-	      && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_comp", 9) != 0)
+	      && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_comp", 9) != 0
+	      && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_del", 8) != 0)
 	    return 0;
 	}