+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * typeck.c (cp_build_unary_op): Diagnose incrementing boolean
+ expressions. Tweak an error message.
+
2016-09-14 Marek Polacek <polacek@redhat.com>
* cp-tree.h (cp_build_unary_op): Change nonconvert parameter type to
complain))
return error_mark_node;
- /* Forbid using -- on `bool'. */
+ /* Forbid using -- or ++ in C++17 on `bool'. */
if (TREE_CODE (declared_type) == BOOLEAN_TYPE)
{
if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR)
{
if (complain & tf_error)
- error ("invalid use of Boolean expression as operand "
- "to %<operator--%>");
+ error ("use of an operand of type %qT in %<operator--%> "
+ "is forbidden", boolean_type_node);
return error_mark_node;
}
+ else
+ {
+ if (cxx_dialect >= cxx1z)
+ {
+ if (complain & tf_error)
+ error ("use of an operand of type %qT in "
+ "%<operator++%> is forbidden in C++1z",
+ boolean_type_node);
+ return error_mark_node;
+ }
+ /* Otherwise, [depr.incr.bool] says this is deprecated. */
+ else if (!in_system_header_at (input_location))
+ warning (OPT_Wdeprecated, "use of an operand of type %qT "
+ "in %<operator++%> is deprecated",
+ boolean_type_node);
+ }
val = boolean_increment (code, arg);
}
else if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR)
+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * c-c++-common/gomp/atomic-12.c: Use -Wno-deprecated.
+ * c-c++-common/gomp/atomic-13.c: Likewise.
+ * c-c++-common/gomp/atomic-14.c: Likewise.
+ * g++.dg/cpp1y/lambda-init11.C: Remove invalid code.
+ * g++.dg/cpp1z/bool-increment1.C: New test.
+ * c-c++-common/pr60439.c: Add dg-warning.
+ * g++.dg/expr/bitfield4.C: Likewise.
+ * g++.dg/expr/bitfield5.C: Likewise.
+ * g++.dg/expr/bitfield6.C: Likewise.
+ * g++.dg/expr/bool1.C: Likewise.
+ * g++.dg/expr/bool3.C: Likewise.
+ * g++.dg/expr/lval3.C: Likewise.
+ * g++.dg/expr/lval4.C: Likewise.
+ * g++.old-deja/g++.jason/bool5.C: Likewise.
+ * g++.dg/expr/bitfield3.C: Adjust dg-error.
+ * g++.dg/other/error18.C: Likewise.
+ * g++.dg/gomp/atomic-14.C: Likewise.
+
2016-09-14 Nathan Sidwell <nathan@acm.org>
PR c++/77539
/* PR middle-end/45423 */
/* { dg-do compile } */
-/* { dg-options "-fopenmp -fdump-tree-gimple -g0" } */
+/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -Wno-deprecated" } */
/* atomicvar should never be referenced in between the barrier and
following #pragma omp atomic_load. */
/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */
/* PR middle-end/45423 */
/* { dg-do compile } */
-/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2" } */
+/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2 -Wno-deprecated" } */
/* atomicvar should never be referenced in between the barrier and
following #pragma omp atomic_load. */
/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */
/* PR middle-end/45423 */
/* { dg-do compile } */
-/* { dg-options "-fopenmp" } */
+/* { dg-options "-fopenmp -Wno-deprecated" } */
#ifdef __cplusplus
bool *baz ();
break;
}
switch (b++) /* { dg-warning "switch condition has" } */
+ /* { dg-warning "is deprecated" "" { target c++ } 134 } */
{
case 3:
break;
foo(3.14f);
foo(0);
foo('a');
- foo(false);
}
--- /dev/null
+// { dg-options -std=c++1z }
+
+int
+fn (bool b)
+{
+ int r = 0;
+
+ r += b++; // { dg-error "use of an operand of type .bool. in .operator\\+\\+. is forbidden in" }
+ r += ++b; // { dg-error "use of an operand of type .bool. in .operator\\+\\+. is forbidden in" }
+ r += b--; // { dg-error "use of an operand of type .bool. in .operator--. is forbidden" }
+ r += --b; // { dg-error "use of an operand of type .bool. in .operator--. is forbidden" }
+
+ return r;
+}
S s;
void f() {
- s.x--; // { dg-error "Boolean expression" }
- --s.x; // { dg-error "Boolean expression" }
+ s.x--; // { dg-error "use of an operand of type .bool." }
+ --s.x; // { dg-error "use of an operand of type .bool." }
}
void f(bool) {}
int main() {
- f(s.x++);
- f(++s.x);
+ f(s.x++); // { dg-warning "deprecated" }
+ f(++s.x); // { dg-warning "deprecated" }
}
S s;
int main() {
- s.x++;
+ s.x++; // { dg-warning "deprecated" }
if (s.x != 1)
return 1;
- ++s.x;
+ ++s.x; // { dg-warning "deprecated" }
if (s.x != 1)
return 2;
}
S s;
void f() {
- ++s.x = false;
+ ++s.x = false; // { dg-warning "deprecated" }
}
my_bool b = false;
int i;
- b++;
- b++;
+ b++; // { dg-warning "deprecated" }
+ b++; // { dg-warning "deprecated" }
i = b;
if (i != 1)
abort ();
my_bool b = false;
int i;
- b++;
- b++;
+ b++; // { dg-warning "deprecated" }
+ b++; // { dg-warning "deprecated" }
i = b;
if (i != 1)
abort ();
{
bool i = 0;
i++ = 3; // { dg-error "" }
+ // { dg-warning "deprecated" "" { target *-*-* } 6 }
}
{
bool i = 0;
++i = 3;
+ // { dg-warning "deprecated" "" { target *-*-* } 6 }
}
foo (void)
{
#pragma omp atomic
- (*baz ())--; // { dg-error "invalid use of Boolean" }
+ (*baz ())--; // { dg-error "use of an operand of type .bool." }
#pragma omp atomic
- --(*baz ()); // { dg-error "invalid use of Boolean" }
+ --(*baz ()); // { dg-error "use of an operand of type .bool." }
#pragma omp atomic
- atomicvar--; // { dg-error "invalid use of Boolean" }
+ atomicvar--; // { dg-error "use of an operand of type .bool." }
#pragma omp atomic
- --atomicvar; // { dg-error "invalid use of Boolean" }
+ --atomicvar; // { dg-error "use of an operand of type .bool." }
return 0;
}
void f(A a)
{
- a.b--; // { dg-error "Boolean expression" }
+ a.b--; // { dg-error "use of an operand of type .bool." }
}
int main ()
{
bool b = false;
- int i = b++;
+ int i = b++; // { dg-warning "deprecated" }
if (i != false || b != true)
return 1;
- i = b++;
+ i = b++; // { dg-warning "deprecated" }
if (i != true || b != true)
return 1;
}
+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * testsuite/libgomp.c++/atomic-3.C: Use -Wno-deprecated.
+
2016-08-19 Jakub Jelinek <jakub@redhat.com>
PR fortran/71014
// { dg-do run }
+// { dg-options "-Wno-deprecated" }
extern "C" void abort (void);
bool v, x1, x2, x3, x4, x5, x6;
+2016-09-14 Marek Polacek <polacek@redhat.com>
+
+ * testsuite/23_containers/vector/debug/insert6_neg.cc: Use
+ -Wno-deprecated.
+
2016-09-14 Christophe Lyon <christophe.lyon@linaro.org>
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
// <http://www.gnu.org/licenses/>.
//
// { dg-do run { xfail *-*-* } }
+// { dg-options "-Wno-deprecated" }
#include <vector>
#include <debug/vector>