diff options
author | Andrew Pinski <andrew_pinski@playstation.sony.com> | 2006-10-28 23:01:59 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2006-10-28 16:01:59 -0700 |
commit | 857d325a640ab62412800b36a89f82f0e424db68 (patch) | |
tree | e4029dbb2c86c3cba024f2ea381d85958738fc53 /gcc | |
parent | 85f37826c69cda5ca54fea63962b46ccd9f15c1b (diff) | |
download | gcc-857d325a640ab62412800b36a89f82f0e424db68.zip gcc-857d325a640ab62412800b36a89f82f0e424db68.tar.gz gcc-857d325a640ab62412800b36a89f82f0e424db68.tar.bz2 |
re PR c++/29295 (++ operator with bool typedef increments or operator -- with bool typedef)
2006-10-28 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR C++/29295
* typeck.c (build_unary_op): Use same_type_p when comparing to
boolean type.
2006-10-28 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR C++/29295
* g++.dg/expr/bool1.C: New test.
* g++.dg/expr/bool2.C: New test.
From-SVN: r118118
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/bool1.C | 21 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/bool2.C | 13 |
5 files changed, 47 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e4b378..e7bf59f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-10-28 Andrew Pinski <andrew_pinski@playstation.sony.com> + + PR C++/29295 + * typeck.c (build_unary_op): Use same_type_p when comparing to + boolean type. + 2006-10-29 Dirk Mueller <dmueller@suse.de> PR c++/29033 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 1faf142..0094323 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 ca0f312..bec28c5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-10-28 Andrew Pinski <andrew_pinski@playstation.sony.com> + + PR C++/29295 + * g++.dg/expr/bool1.C: New test. + * g++.dg/expr/bool2.C: New test. + 2006-10-28 Tobias Burnus <burnus@net-b.de> 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 0000000..bfb40e3 --- /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 0000000..39d93c0 --- /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; +} + |