From 9a1c0fd9f2a59bbbfb4801064bf7cad898389e70 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
Date: Wed, 21 Oct 2009 10:12:55 +0000
Subject: [PATCH] decl.c (gnat_to_gnu_entity): Do not create a new TYPE_DECL
 when a type is padded if...

	* gcc-interfaces/decl.c (gnat_to_gnu_entity): Do not create a new
	TYPE_DECL when a type is padded if there is already one and reset
	TYPE_STUB_DECL in this case.

From-SVN: r153053
---
 gcc/ada/ChangeLog            | 6 ++++++
 gcc/ada/gcc-interface/decl.c | 7 +++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6fef8cc453a5..5d69cee05942 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2009-10-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gcc-interfaces/decl.c (gnat_to_gnu_entity): Do not create a new
+	TYPE_DECL when a type is padded if there is already one and reset
+	TYPE_STUB_DECL in this case.
+
 2009-10-21  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gcc-interfaces/utils.c (create_subprog_decl): Do not redefine
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index a2af17981703..70ced844fb6a 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -4436,7 +4436,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
 	 us when we make the new TYPE_DECL below.  */
       if (gnu_size || align > 0)
 	gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity,
-				   false, true, definition, false);
+				   false, !gnu_decl, definition, false);
 
       if (TYPE_IS_PADDING_P (gnu_type))
 	{
@@ -4555,7 +4555,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
 				     !Comes_From_Source (gnat_entity),
 				     debug_info_p, gnat_entity);
       else
-	TREE_TYPE (gnu_decl) = gnu_type;
+	{
+	  TREE_TYPE (gnu_decl) = gnu_type;
+	  TYPE_STUB_DECL (gnu_type) = gnu_decl;
+	}
     }
 
   if (is_type && !TYPE_IS_DUMMY_P (TREE_TYPE (gnu_decl)))
-- 
GitLab