From f8125f0c9ce43aac6d7a96753e4617af68ee0009 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 30 Nov 2015 11:34:31 +0000 Subject: * gcc-interface/utils2.c (gnat_invariant_expr): Add type conversions. From-SVN: r231063 --- gcc/ada/ChangeLog | 4 ++++ gcc/ada/gcc-interface/utils2.c | 4 +++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/loop_optimization22.adb | 16 ++++++++++++++++ gcc/testsuite/gnat.dg/loop_optimization22.ads | 7 +++++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/loop_optimization22.adb create mode 100644 gcc/testsuite/gnat.dg/loop_optimization22.ads (limited to 'gcc') diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a90fa64..cc0add2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,9 @@ 2015-11-30 Eric Botcazou + * gcc-interface/utils2.c (gnat_invariant_expr): Add type conversions. + +2015-11-30 Eric Botcazou + * gcc-interface/ada-tree.h (TYPE_MAX_ALIGN): New macro. * gcc-interface/decl.c (gnat_to_gnu_entity): Do not set PACKED to -2. Remove obsolete code setting the alignment on some atomic types. diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 79e9b2f..a74b8a8 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -2860,7 +2860,9 @@ gnat_invariant_expr (tree expr) tree op0 = gnat_invariant_expr (TREE_OPERAND (expr, 0)); tree op1 = TREE_OPERAND (expr, 1); if (op0 && TREE_CONSTANT (op1)) - return fold_build2 (TREE_CODE (expr), type, op0, op1); + return + fold_build2 (TREE_CODE (expr), type, + fold_convert (type, op0), fold_convert (type, op1)); else return NULL_TREE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e7a3058..e31b7f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2015-11-30 Eric Botcazou + * gnat.dg/loop_optimization22.ad[sb]: New test. + +2015-11-30 Eric Botcazou + * gnat.dg/specs/rep_clause5.ads: New test. 2015-11-29 Jan Hubicka diff --git a/gcc/testsuite/gnat.dg/loop_optimization22.adb b/gcc/testsuite/gnat.dg/loop_optimization22.adb new file mode 100644 index 0000000..7fb307b --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization22.adb @@ -0,0 +1,16 @@ +-- { dg-do compile } +-- { dg-options "-O" } + +pragma Overflow_Mode (Minimized); + +package body Loop_Optimization22 is + + procedure Foo (X : Discrim_Type) is + H : array (1 .. Integer (X.Count) + 1) of Float; + begin + for I in 1 .. X.Count loop + H (Integer(I) + 1):= 0.0; + end loop; + end; + +end Loop_Optimization22; diff --git a/gcc/testsuite/gnat.dg/loop_optimization22.ads b/gcc/testsuite/gnat.dg/loop_optimization22.ads new file mode 100644 index 0000000..ec3ac0d --- /dev/null +++ b/gcc/testsuite/gnat.dg/loop_optimization22.ads @@ -0,0 +1,7 @@ +package Loop_Optimization22 is + + type Discrim_Type (Count : Positive) is null record; + + procedure Foo (X : Discrim_Type); + +end Loop_Optimization22; -- cgit v1.1