aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c2
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/expr/bool1.C21
-rw-r--r--gcc/testsuite/g++.dg/expr/bool2.C13
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;
+}
+