diff mbox series

Fix PR ada/98740

Message ID 4674484.f4mTRMsDmp@fomalhaut
State New
Headers show
Series Fix PR ada/98740 | expand

Commit Message

Eric Botcazou Jan. 19, 2021, 9:48 a.m. UTC
It's a long-standing GENERIC tree sharing issue.

Tested on x86_64-suse-linux, applied on the mainline, 10 and 9 branches.


2021-01-19  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/98740
	* gcc-interface/trans.c (add_decl_expr): Always mark TYPE_ADA_SIZE.
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 4ab26d3e2dd..6402c73ded0 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -8479,15 +8479,16 @@  add_decl_expr (tree gnu_decl, Node_Id gnat_node)
 	  MARK_VISITED (DECL_SIZE_UNIT (gnu_decl));
 	  MARK_VISITED (DECL_INITIAL (gnu_decl));
 	}
-      /* In any case, we have to deal with our own TYPE_ADA_SIZE field.  */
-      else if (TREE_CODE (gnu_decl) == TYPE_DECL
-	       && RECORD_OR_UNION_TYPE_P (type)
-	       && !TYPE_FAT_POINTER_P (type))
-	MARK_VISITED (TYPE_ADA_SIZE (type));
     }
   else
     add_stmt_with_node (gnu_stmt, gnat_node);
 
+  /* Mark our TYPE_ADA_SIZE field now since it will not be gimplified.  */
+  if (TREE_CODE (gnu_decl) == TYPE_DECL
+      && RECORD_OR_UNION_TYPE_P (type)
+      && !TYPE_FAT_POINTER_P (type))
+    MARK_VISITED (TYPE_ADA_SIZE (type));
+
   /* If this is a variable and an initializer is attached to it, it must be
      valid for the context.  Similar to init_const in create_var_decl.  */
   if (TREE_CODE (gnu_decl) == VAR_DECL