OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 2 Sep 2007 13:02:31 +0000 (13:02 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 2 Sep 2007 13:02:31 +0000 (13:02 +0000)
2007-09-02  Paolo Carlini  <pcarlini@suse.de>

PR c++/33208
* typeck.c (build_unary_op): Fix error message for
Boolean expression as operand to operator--.

/testsuite
2007-09-02  Paolo Carlini  <pcarlini@suse.de>

PR c++/33208
* g++.dg/other/error18.C: New.
* g++.dg/expr/bitfield3.C: Adjust.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128025 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 7b1b70f..43883e6 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-02  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/33208
+       * typeck.c (build_unary_op): Fix error message for
+       Boolean expression as operand to operator--.
+
 2007-09-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * tree.c (pod_type_p, zero_init_p): Use strip_array_types.
index b57fbe5..ae39b59 100644 (file)
@@ -4323,7 +4323,8 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert)
          {
            if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR)
              {
-               error ("invalid use of %<--%> on bool variable %qD", arg);
+               error ("invalid use of Boolean expression as operand "
+                      "to %<operator--%>");
                return error_mark_node;
              }
            val = boolean_increment (code, arg);
index 3efc896..9508d1a 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-02  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/33208
+       * g++.dg/other/error18.C: New.
+       * g++.dg/expr/bitfield3.C: Adjust.
+
 2007-09-02  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR fortran/33276
index 7b856e9..3221263 100644 (file)
@@ -7,6 +7,6 @@ struct S {
 S s;
 
 void f() {
-  s.x--; // { dg-error "bool" }
-  --s.x; // { dg-error "bool" }
+  s.x--; // { dg-error "Boolean expression" }
+  --s.x; // { dg-error "Boolean expression" }
 }
diff --git a/gcc/testsuite/g++.dg/other/error18.C b/gcc/testsuite/g++.dg/other/error18.C
new file mode 100644 (file)
index 0000000..9e4d21c
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/33208
+
+struct A
+{
+  bool b;
+};
+
+void f(A a)
+{
+  a.b--; // { dg-error "Boolean expression" }
+}