From: Andrew Pinski Date: Sat, 28 Oct 2006 23:01:59 +0000 (+0000) Subject: re PR c++/29295 (++ operator with bool typedef increments or operator -- with bool... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=857d325a640ab62412800b36a89f82f0e424db68;p=gcc.git re PR c++/29295 (++ operator with bool typedef increments or operator -- with bool typedef) 2006-10-28 Andrew Pinski PR C++/29295 * typeck.c (build_unary_op): Use same_type_p when comparing to boolean type. 2006-10-28 Andrew Pinski PR C++/29295 * g++.dg/expr/bool1.C: New test. * g++.dg/expr/bool2.C: New test. From-SVN: r118118 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e4b378e035..e7bf59f5a14 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-10-28 Andrew Pinski + + PR C++/29295 + * typeck.c (build_unary_op): Use same_type_p when comparing to + boolean type. + 2006-10-29 Dirk Mueller PR c++/29033 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1faf1423b2e..0094323db75 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4192,7 +4192,7 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert) return error_mark_node; /* Forbid using -- on `bool'. */ - if (TREE_TYPE (arg) == boolean_type_node) + if (same_type_p (TREE_TYPE (arg), boolean_type_node)) { if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca0f3127fd5..bec28c524bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-10-28 Andrew Pinski + + PR C++/29295 + * g++.dg/expr/bool1.C: New test. + * g++.dg/expr/bool2.C: New test. + 2006-10-28 Tobias Burnus PR fortran/28224 diff --git a/gcc/testsuite/g++.dg/expr/bool1.C b/gcc/testsuite/g++.dg/expr/bool1.C new file mode 100644 index 00000000000..bfb40e33092 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/bool1.C @@ -0,0 +1,21 @@ +// { dg-do run } +// PR C++/29295 +// make sure that a typedef for a bool will have the +// the same results as a bool itself. + +extern "C" void abort(); +typedef bool my_bool; +int main() +{ + my_bool b = false; + int i; + + b++; + b++; + i = b; + if (i != 1) + abort (); + return 0; +} + + diff --git a/gcc/testsuite/g++.dg/expr/bool2.C b/gcc/testsuite/g++.dg/expr/bool2.C new file mode 100644 index 00000000000..39d93c0af9d --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/bool2.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// make sure that a typedef for a bool will have the +// the same results as a bool itself. + + +typedef bool my_bool; +int main() +{ + my_bool b = false; + b--; // { dg-error "" } + return 0; +} +