]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gimple-fold.c (canonicalize_constructor_val): Strip only useless type conversions.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 19 Jul 2012 21:22:04 +0000 (21:22 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 19 Jul 2012 21:22:04 +0000 (21:22 +0000)
* gimple-fold.c (canonicalize_constructor_val): Strip only useless type
conversions.

From-SVN: r189685

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 a14b3d91fd55494ff87f4dbc8705c8117e826d8b..1a3d4017f516454b1bd61077251b98bf2d4bc67d 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  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/53942
index b97719a4c1cd00558eea0b7463b1854ab6e2ffb2..ccdeb34677f6680dbb3cc479284b1b2ab4e58256 100644 (file)
@@ -139,7 +139,7 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl)
 tree
 canonicalize_constructor_val (tree cval, tree from_decl)
 {
-  STRIP_NOPS (cval);
+  STRIP_USELESS_TYPE_CONVERSION (cval);
   if (TREE_CODE (cval) == POINTER_PLUS_EXPR
       && TREE_CODE (TREE_OPERAND (cval, 1)) == INTEGER_CST)
     {
index 79bdd9591321546f02dadf79bc08b79e2d41f2cc..740d26bdf35ed5ee155b415946ad567b526b8a49 100644 (file)
@@ -1,3 +1,8 @@
+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.
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;