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

2017-05-15  Pierre-Marie de Rodat  <dero...@adacore.com>

        * gcc-interface/utils.c (can_materialize_object_renaming_p):
        Synchronize with GNAT's Exp_Dbug.Debug_Renaming_Declaration:
        process Original_Node instead of expanded names.


2017-05-15  Pierre-Marie de Rodat  <dero...@adacore.com>

        * gnat.dg/specs/pack13.ads: New test.

-- 
Eric Botcazou
Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c	(revision 248051)
+++ gcc-interface/utils.c	(working copy)
@@ -5431,11 +5431,16 @@ can_materialize_object_renaming_p (Node_
 {
   while (true)
     {
+      expr = Original_Node (expr);
+
       switch Nkind (expr)
 	{
 	case N_Identifier:
 	case N_Expanded_Name:
-	  return true;
+	  if (!Present (Renamed_Object (Entity (expr))))
+	    return true;
+	  expr = Renamed_Object (Entity (expr));
+	  break;
 
 	case N_Selected_Component:
 	  {
-- { dg-do compile }

package Pack13 is

  generic
    type Value_Type is private;
    Value : in out Value_Type;
  package G is end G;

  type Rec is record
    B : Boolean;
  end record;
  for Rec use record
    B at 0 range 8 .. 8;
  end record;
  for Rec'size use 9;

  type Arr is array (Boolean) of Rec;
  pragma Pack (Arr);

  A : Arr;

  package My_G is new G (Boolean, A(True).B);

end Pack13;

Reply via email to