diff options
author | Andrew Pinski <pinskia@gcc.gnu.org> | 2009-09-17 16:03:55 -0700 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2009-09-17 16:03:55 -0700 |
commit | 66be89f022efde50e624af8f67c67b3e4875df5c (patch) | |
tree | f0fd7e2928c9eb9dc2b97430594e87df6200f816 | |
parent | 695a8e6210f36efd711a23ab4b2bd4f1cbf8a857 (diff) | |
download | gcc-66be89f022efde50e624af8f67c67b3e4875df5c.zip gcc-66be89f022efde50e624af8f67c67b3e4875df5c.tar.gz gcc-66be89f022efde50e624af8f67c67b3e4875df5c.tar.bz2 |
re PR c++/39365 (++ operator with volatile bool increments)
2009-09-17 Andrew Pinski <pinskia@gcc.gnu.org>
PR c++/39365
* typeck.c (cp_build_unary_op): Check TREE_CODE for bools instead of
using same_type_p.
(convert_for_assignment): Likewise.
* cvt.c (type_promotes_to): Likewise.
2009-09-17 Andrew Pinski <pinskia@gcc.gnu.org>
PR c++/39365
* g++.dg/expr/bool3.C: New test.
* g++.dg/expr/bool4.C: New test.
From-SVN: r151823
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/bool3.C | 21 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/bool4.C | 13 |
6 files changed, 51 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 93b90b5..8bf0dde 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-09-17 Andrew Pinski <pinskia@gcc.gnu.org> + + PR c++/39365 + * g++.dg/expr/bool3.C: New test. + * g++.dg/expr/bool4.C: New test. + 2009-09-14 Richard Henderson <rth@redhat.com> Jakub Jelinek <jakub@redhat.com> diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index cdc6a10..aff002d 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1287,7 +1287,7 @@ type_promotes_to (tree type) /* bool always promotes to int (not unsigned), even if it's the same size. */ - if (type == boolean_type_node) + if (TREE_CODE (type) == BOOLEAN_TYPE) type = integer_type_node; /* Normally convert enums to int, but convert wide enums to something diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 53165b3..0595113 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4556,7 +4556,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, return error_mark_node; /* Forbid using -- on `bool'. */ - if (same_type_p (declared_type, boolean_type_node)) + if (TREE_CODE (declared_type) == BOOLEAN_TYPE) { if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR) { @@ -6787,7 +6787,7 @@ convert_for_assignment (tree type, tree rhs, /* If -Wparentheses, warn about a = b = c when a has type bool and b does not. */ if (warn_parentheses - && type == boolean_type_node + && TREE_CODE (type) == BOOLEAN_TYPE && TREE_CODE (rhs) == MODIFY_EXPR && !TREE_NO_WARNING (rhs) && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 67cf3a9..c53270b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2009-09-17 Andrew Pinski <pinskia@gcc.gnu.org> + + PR c++/39365 + * typeck.c (cp_build_unary_op): Check TREE_CODE for bools instead of + using same_type_p. + (convert_for_assignment): Likewise. + * cvt.c (type_promotes_to): Likewise. + 2009-09-17 Janis Johnson <janis187@us.ibm.com> * gcc/testsuite/gcc.dg/dfp/dfp-dbg.h: Define EXTERN. diff --git a/gcc/testsuite/g++.dg/expr/bool3.C b/gcc/testsuite/g++.dg/expr/bool3.C new file mode 100644 index 0000000..61669e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/bool3.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 volatile 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/bool4.C b/gcc/testsuite/g++.dg/expr/bool4.C new file mode 100644 index 0000000..dce51ec --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/bool4.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 volatile bool my_bool; +int main() +{ + my_bool b = false; + b--; // { dg-error "" } + return 0; +} + |