OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity): Do not set DECL_ARTIFICIAL
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Nov 2010 11:35:08 +0000 (11:35 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Nov 2010 11:35:08 +0000 (11:35 +0000)
on the reused DECL node coming from a renamed object.
Set DECL_IGNORED_P on the DECL node built for renaming entities if they
don't need debug info.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166530 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/unchecked_convert7.adb [new file with mode: 0644]

index c768d86..0e522fd 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-10  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity): Do not set DECL_ARTIFICIAL
+       on the reused DECL node coming from a renamed object.
+       Set DECL_IGNORED_P on the DECL node built for renaming entities if they
+       don't need debug info.
+
 2010-11-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/utils.c (save_gnu_tree): Improve comments.
index c2b8278..7181653 100644 (file)
@@ -4894,13 +4894,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
        Set_RM_Size (gnat_entity, annotate_value (rm_size (gnu_type)));
     }
 
-  if (!Comes_From_Source (gnat_entity) && DECL_P (gnu_decl))
-    DECL_ARTIFICIAL (gnu_decl) = 1;
+  /* If we really have a ..._DECL node, set a couple of flags on it.  But we
+     cannot do that if we are reusing the ..._DECL node made for a renamed
+     object, since the predicates don't apply to it but to GNAT_ENTITY.  */
+  if (DECL_P (gnu_decl) && !(Present (Renamed_Object (gnat_entity)) && saved))
+    {
+      if (!Comes_From_Source (gnat_entity))
+       DECL_ARTIFICIAL (gnu_decl) = 1;
 
-  if (!debug_info_p && DECL_P (gnu_decl)
-      && TREE_CODE (gnu_decl) != FUNCTION_DECL
-      && No (Renamed_Object (gnat_entity)))
-    DECL_IGNORED_P (gnu_decl) = 1;
+      if (!debug_info_p && TREE_CODE (gnu_decl) != FUNCTION_DECL)
+       DECL_IGNORED_P (gnu_decl) = 1;
+    }
 
   /* If we haven't already, associate the ..._DECL node that we just made with
      the input GNAT entity node.  */
index e4ae2ac..32ee4fa 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-10  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/unchecked_convert7.adb: New test.
+
 2010-11-10  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/46398
diff --git a/gcc/testsuite/gnat.dg/unchecked_convert7.adb b/gcc/testsuite/gnat.dg/unchecked_convert7.adb
new file mode 100644 (file)
index 0000000..502459b
--- /dev/null
@@ -0,0 +1,36 @@
+-- { dg-do compile }
+-- { dg-options "-g -gnatVa" }
+
+with Unchecked_Conversion;
+
+procedure Unchecked_Convert7 is
+
+  type BPA is array (1 .. 23) of Boolean;
+  pragma Pack (BPA);
+  for BPA'Size use 23;
+
+  subtype Byte is Natural range 0 .. 255;
+
+  type R is
+    record
+      S : Boolean;
+      E : Byte;
+      F : BPA;
+    end record;
+
+  for R use
+    record
+      S at 0 range 0 .. 0;
+      E at 0 range 1 .. 8;
+      F at 0 range 9 .. 31;
+    end record;
+  for R'Size use 32;
+
+  function Conversion
+    is new Unchecked_Conversion (Source => R, Target => Float);
+
+  F : Float := Conversion (R'(False, Byte'Last, (others => False)));
+
+begin
+  null;
+end;