From 8bcebc69b873883d1180382c9599ff563d9b9264 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sun, 2 Sep 2007 13:02:31 +0000 Subject: [PATCH] re PR c++/33208 (Broken diagnostic: 'component_ref' not supported by dump_decl) /cp 2007-09-02 Paolo Carlini PR c++/33208 * typeck.c (build_unary_op): Fix error message for Boolean expression as operand to operator--. /testsuite 2007-09-02 Paolo Carlini PR c++/33208 * g++.dg/other/error18.C: New. * g++.dg/expr/bitfield3.C: Adjust. From-SVN: r128025 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck.c | 3 ++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/expr/bitfield3.C | 4 ++-- gcc/testsuite/g++.dg/other/error18.C | 11 +++++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/error18.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7b1b70fa5e9..43883e65973 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-09-02 Paolo Carlini + + PR c++/33208 + * typeck.c (build_unary_op): Fix error message for + Boolean expression as operand to operator--. + 2007-09-01 Kaveh R. Ghazi * tree.c (pod_type_p, zero_init_p): Use strip_array_types. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index b57fbe5455f..ae39b59bb07 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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 %"); return error_mark_node; } val = boolean_increment (code, arg); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3efc89695ee..9508d1adfe7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-09-02 Paolo Carlini + + PR c++/33208 + * g++.dg/other/error18.C: New. + * g++.dg/expr/bitfield3.C: Adjust. + 2007-09-02 H.J. Lu PR fortran/33276 diff --git a/gcc/testsuite/g++.dg/expr/bitfield3.C b/gcc/testsuite/g++.dg/expr/bitfield3.C index 7b856e9e8b8..3221263a906 100644 --- a/gcc/testsuite/g++.dg/expr/bitfield3.C +++ b/gcc/testsuite/g++.dg/expr/bitfield3.C @@ -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 index 00000000000..9e4d21cfde0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error18.C @@ -0,0 +1,11 @@ +// PR c++/33208 + +struct A +{ + bool b; +}; + +void f(A a) +{ + a.b--; // { dg-error "Boolean expression" } +} -- 2.30.2