Index: testsuite/g++.dg/expr/bool3.C =================================================================== --- testsuite/g++.dg/expr/bool3.C (revision 0) +++ testsuite/g++.dg/expr/bool3.C (revision 0) @@ -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; +} + + Index: testsuite/g++.dg/expr/bool4.C =================================================================== --- testsuite/g++.dg/expr/bool4.C (revision 0) +++ testsuite/g++.dg/expr/bool4.C (revision 0) @@ -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; +} + Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 146200) +++ cp/typeck.c (working copy) @@ -4468,7 +4468,7 @@ cp_build_unary_op (enum tree_code code, 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) {