OSDN Git Service

* gimple-fold.c (canonicalize_constructor_val): Strip only useless type
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Jul 2012 21:26:17 +0000 (21:26 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Jul 2012 21:26:17 +0000 (21:26 +0000)
conversions.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@189686 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/aggr20.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/aggr20.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/aggr20_pkg.ads [new file with mode: 0644]

index 7040eaf..b75171d 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-19  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gimple-fold.c (canonicalize_constructor_val): Strip only useless type
+       conversions.
+
 2012-07-19  Richard Guenther  <rguenther@suse.de>
            Eric Botcazou  <ebotcazou@adacore.com>
 
index de8919e..5980854 100644 (file)
@@ -115,7 +115,7 @@ can_refer_decl_in_current_unit_p (tree decl)
 tree
 canonicalize_constructor_val (tree cval)
 {
-  STRIP_NOPS (cval);
+  STRIP_USELESS_TYPE_CONVERSION (cval);
   if (TREE_CODE (cval) == POINTER_PLUS_EXPR
       && TREE_CODE (TREE_OPERAND (cval, 1)) == INTEGER_CST)
     {
index 8d8a615..21ef1f3 100644 (file)
@@ -1,5 +1,10 @@
 2012-07-19  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gnat.dg/aggr20.ad[sb]: New test.
+       * gnat.dg/aggr20_pkg.ads: New helper.
+
+2012-07-19  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gnat.dg/derived_type3.adb: New test.
        * gnat.dg/derived_type3_pkg.ad[sb]: New helper.
 
diff --git a/gcc/testsuite/gnat.dg/aggr20.adb b/gcc/testsuite/gnat.dg/aggr20.adb
new file mode 100644 (file)
index 0000000..85111e2
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+
+package body Aggr20 is
+
+   procedure Proc (R : out Rec3) is
+   begin
+      R := (Callback => Nil_Rec2);
+   end;
+
+end Aggr20;
diff --git a/gcc/testsuite/gnat.dg/aggr20.ads b/gcc/testsuite/gnat.dg/aggr20.ads
new file mode 100644 (file)
index 0000000..6405cae
--- /dev/null
@@ -0,0 +1,24 @@
+with Aggr20_Pkg; use Aggr20_Pkg;
+with System;
+
+package Aggr20 is
+
+   type Rec1 is record
+      Address : System.Address;
+   end record;
+
+   Nil_Rec1 : constant Rec1 := (Address => Default_Nil_Address);
+
+   type Rec2 is record
+      Callback : Rec1;
+   end record;
+
+   Nil_Rec2 : constant Rec2 := (Callback => Nil_Rec1);
+
+   type Rec3 is record
+      Callback : Rec2;
+   end record;
+
+   procedure Proc (R : out Rec3);
+
+end Aggr20;
diff --git a/gcc/testsuite/gnat.dg/aggr20_pkg.ads b/gcc/testsuite/gnat.dg/aggr20_pkg.ads
new file mode 100644 (file)
index 0000000..66f5bd5
--- /dev/null
@@ -0,0 +1,9 @@
+with System;
+
+package Aggr20_Pkg is
+
+   procedure Proc;
+
+   Default_Nil_Address : constant System.Address := Proc'Address;
+
+end Aggr20_Pkg;