aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2008-08-02 10:49:51 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2008-08-02 10:49:51 +0000
commitd2143736bb340bc15421f82fd3cf99d2e06e84a3 (patch)
tree8df14879b8e45b704c54b737dd398b980efc4aa3
parentc9234c8d54b09ba565fc10cee2f2e230c4f012e2 (diff)
downloadgcc-d2143736bb340bc15421f82fd3cf99d2e06e84a3.zip
gcc-d2143736bb340bc15421f82fd3cf99d2e06e84a3.tar.gz
gcc-d2143736bb340bc15421f82fd3cf99d2e06e84a3.tar.bz2
utils2.c (build_binary_op): New case.
* gcc-interface/utils2.c (build_binary_op) <PLUS_EXPR, MINUS_EXPR>: New case. Convert BOOLEAN_TYPE operation to the default integer type. From-SVN: r138552
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/utils2.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/boolean_expr2.adb18
4 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 5819c49..ab0d02f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-02 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/utils2.c (build_binary_op) <PLUS_EXPR, MINUS_EXPR>:
+ New case. Convert BOOLEAN_TYPE operation to the default integer type.
+
2008-08-01 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada-tree.h (DECL_PARM_ALT): Now DECL_PARM_ALT_TYPE.
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index 1424ac8..d1a6786 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -986,7 +986,6 @@ build_binary_op (enum tree_code op_code, tree result_type,
outputs. */
if (modulus && integer_pow2p (modulus))
modulus = NULL_TREE;
-
goto common;
case COMPLEX_EXPR:
@@ -1011,6 +1010,15 @@ build_binary_op (enum tree_code op_code, tree result_type,
right_operand = convert (sizetype, right_operand);
break;
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ /* Avoid doing arithmetics in BOOLEAN_TYPE like the other compilers.
+ Contrary to C, Ada doesn't allow arithmetics in Standard.Boolean
+ but we can generate addition or subtraction for 'Succ and 'Pred. */
+ if (operation_type && TREE_CODE (operation_type) == BOOLEAN_TYPE)
+ operation_type = left_base_type = right_base_type = integer_type_node;
+ goto common;
+
default:
common:
/* The result type should be the same as the base types of the
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4aacfda..b9f542a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-08-02 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/boolean_expr2.adb: New test.
+
2008-08-01 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/36991
diff --git a/gcc/testsuite/gnat.dg/boolean_expr2.adb b/gcc/testsuite/gnat.dg/boolean_expr2.adb
new file mode 100644
index 0000000..8bdcb84
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/boolean_expr2.adb
@@ -0,0 +1,18 @@
+-- { dg-do run }
+
+procedure Boolean_Expr2 is
+
+ function Ident_Bool (B : Boolean) return Boolean is
+ begin
+ return B;
+ end;
+
+begin
+ if Boolean'Succ (Ident_Bool(False)) /= True then
+ raise Program_Error;
+ end if;
+
+ if Boolean'Pred (Ident_Bool(True)) /= False then
+ raise Program_Error;
+ end if;
+end;