Patchwork [Ada] Fix link failure for renamed aliased object with unconstrained type

login
register
mail settings
Submitter Eric Botcazou
Date May 26, 2013, 8:41 a.m.
Message ID <1703919.sGfrYFKoEp@polaris>
Download mbox | patch
Permalink /patch/246371/
State New
Headers show

Comments

Eric Botcazou - May 26, 2013, 8:41 a.m.
It's a rather obscure case and comes from the change of representation for 
aliased objects with unconstrained nominal type that we made last year.

Tested on x86_64-suse-linux, applied on the mainline.


2013-05-26  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Always build the
	UNC variable for aliased objects with unconstrained nominal subtype.

Patch

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 199330)
+++ gcc-interface/decl.c	(working copy)
@@ -1411,26 +1411,19 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 	       just above, we have nothing to do here.  */
 	    if (!TYPE_IS_THIN_POINTER_P (gnu_type))
 	      {
-	        gnu_size = NULL_TREE;
-		used_by_ref = true;
+		tree gnu_unc_var
+		   = create_var_decl (concat_name (gnu_entity_name, "UNC"),
+				      NULL_TREE, gnu_type, gnu_expr,
+				      const_flag, Is_Public (gnat_entity),
+				      imported_p || !definition, static_p,
+				      NULL, gnat_entity);
+		gnu_expr
+		  = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_unc_var);
+		TREE_CONSTANT (gnu_expr) = 1;
 
-		if (definition && !imported_p)
-		  {
-		    tree gnu_unc_var
-		      = create_var_decl (concat_name (gnu_entity_name, "UNC"),
-					 NULL_TREE, gnu_type, gnu_expr,
-					 const_flag, Is_Public (gnat_entity),
-					 false, static_p, NULL, gnat_entity);
-		    gnu_expr
-		      = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_unc_var);
-		    TREE_CONSTANT (gnu_expr) = 1;
-		    const_flag = true;
-		  }
-		else
-		  {
-		    gnu_expr = NULL_TREE;
-		    const_flag = false;
-		  }
+		gnu_size = NULL_TREE;
+		used_by_ref = true;
+		const_flag = true;
 	      }
 
 	    gnu_type