]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39365 (++ operator with volatile bool increments)
authorAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 17 Sep 2009 23:03:55 +0000 (16:03 -0700)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 17 Sep 2009 23:03:55 +0000 (16:03 -0700)
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

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

index 93b90b5c0ee57eea6ba1e78c13587c319e1a08fa..8bf0dde422651b3b2234b9e91697d45aa2e2cbd1 100644 (file)
@@ -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>
 
index cdc6a10a825e9fcff6d1b967f8dd2852af997abf..aff002dc6666a79ed94df2cc8171710c8fc1bb35 100644 (file)
@@ -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
index 53165b38dc30aa77e8813e086870a872eacaaf1d..059511396c5f538203a8efc365a208b02e7befc4 100644 (file)
@@ -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
index 67cf3a969d8a5852dc01c1b7f33b3ed946db831c..c53270b79ce5e0fb398225113954b4d99d652317 100644 (file)
@@ -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 (file)
index 0000000..61669e2
--- /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 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 (file)
index 0000000..dce51ec
--- /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 volatile bool my_bool;
+int main()
+{
+  my_bool b = false;
+  b--; // { dg-error "" }
+  return 0;
+}
+