re PR c++/29295 (++ operator with bool typedef increments or operator -- with bool...
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Sat, 28 Oct 2006 23:01:59 +0000 (23:01 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sat, 28 Oct 2006 23:01:59 +0000 (16:01 -0700)
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

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/expr/bool1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/expr/bool2.C [new file with mode: 0644]

index 7e4b378e035ceba5d69d993d18ffd3e36a9db50e..e7bf59f5a14bfedda1107f3e162f465eec3e8e82 100644 (file)
@@ -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
index 1faf1423b2efd665f1b0eb1740a954c841883c65..0094323db753ce6a7eb98dd5c8e224a3a33ae101 100644 (file)
@@ -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)
              {
index ca0f3127fd5235b5b0bbde7d5b9545402aa15e3b..bec28c524bf92f1686e6343b17c25519fc76c7d3 100644 (file)
@@ -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 (file)
index 0000000..bfb40e3
--- /dev/null
@@ -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 (file)
index 0000000..39d93c0
--- /dev/null
@@ -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;
+}
+