summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-27 10:59:18 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-27 10:59:18 +0000
commitfc1a63ef2fdbf6c8d7b41c97a486e01e14efb810 (patch)
tree4c8279dfa63fab4edfa5cd6b1860bb5c2bf3d48e
parentefce4ba6431ac2aeb3c31a5775cf671b5ea65709 (diff)
downloadgcc-fc1a63ef2fdbf6c8d7b41c97a486e01e14efb810.tar.gz
2014-10-27 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Remove superfluous computation for the max size. <E_Array_Subtype>: Likewise. Make sure that the max size calculation does not overflow at compile time. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216726 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/gcc-interface/decl.c37
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/entry_queues2.adb45
4 files changed, 76 insertions, 17 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 4822a094e62..aa9586ae57e 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2014-10-27 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Remove
+ superfluous computation for the max size.
+ <E_Array_Subtype>: Likewise. Make sure that the max size calculation
+ does not overflow at compile time.
+
2014-10-13 Eric Botcazou <ebotcazou@adacore.com>
Alan Modra <amodra@gmail.com>
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 52452ce7920..95bc778b4bd 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -2200,11 +2200,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
tree gnu_max
= convert (sizetype, TYPE_MAX_VALUE (gnu_index_type));
tree gnu_this_max
- = size_binop (MAX_EXPR,
- size_binop (PLUS_EXPR, size_one_node,
- size_binop (MINUS_EXPR,
- gnu_max, gnu_min)),
- size_zero_node);
+ = size_binop (PLUS_EXPR, size_one_node,
+ size_binop (MINUS_EXPR, gnu_max, gnu_min));
if (TREE_CODE (gnu_this_max) == INTEGER_CST
&& TREE_OVERFLOW (gnu_this_max))
@@ -2525,20 +2522,26 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_max_size = NULL_TREE;
else
{
- tree gnu_this_max
- = size_binop (MAX_EXPR,
- size_binop (PLUS_EXPR, size_one_node,
- size_binop (MINUS_EXPR,
+ tree gnu_this_max;
+
+ /* Use int_const_binop if the bounds are constant to
+ avoid any unwanted overflow. */
+ if (TREE_CODE (gnu_base_min) == INTEGER_CST
+ && TREE_CODE (gnu_base_max) == INTEGER_CST)
+ gnu_this_max
+ = int_const_binop (PLUS_EXPR, size_one_node,
+ int_const_binop (MINUS_EXPR,
gnu_base_max,
- gnu_base_min)),
- size_zero_node);
-
- if (TREE_CODE (gnu_this_max) == INTEGER_CST
- && TREE_OVERFLOW (gnu_this_max))
- gnu_max_size = NULL_TREE;
+ gnu_base_min));
else
- gnu_max_size
- = size_binop (MULT_EXPR, gnu_max_size, gnu_this_max);
+ gnu_this_max
+ = size_binop (PLUS_EXPR, size_one_node,
+ size_binop (MINUS_EXPR,
+ gnu_base_max,
+ gnu_base_min));
+
+ gnu_max_size
+ = size_binop (MULT_EXPR, gnu_max_size, gnu_this_max);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d6050e24b4c..175a1cf91e6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-10-27 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/entry_queues2.adb: New test.
+
2014-10-25 Yury Gribov <y.gribov@samsung.com>
PR sanitizer/63638
diff --git a/gcc/testsuite/gnat.dg/entry_queues2.adb b/gcc/testsuite/gnat.dg/entry_queues2.adb
new file mode 100644
index 00000000000..a1445cebdcb
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/entry_queues2.adb
@@ -0,0 +1,45 @@
+-- { dg-do compile }
+
+procedure Entry_Queues2 is
+
+ F1 : Integer := 17;
+
+ generic
+ type T is limited private;
+ procedure Check;
+
+ procedure Check is
+ begin
+ declare
+ type Poe is new T;
+ begin
+ declare
+ type Arr is array (1 .. 2) of Poe;
+ X : Arr;
+ pragma Unreferenced (X);
+ begin
+ null;
+ end;
+ end;
+ end;
+
+begin
+
+ declare
+ protected type Poe (D3 : Integer := F1) is
+ entry E (D3 .. F1); -- F1 evaluated
+ end Poe;
+ protected body Poe is
+ entry E (for I in D3 .. F1) when True is
+ begin
+ null;
+ end E;
+ end Poe;
+
+ procedure Chk is new Check (Poe);
+
+ begin
+ Chk;
+ end;
+
+end;