diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 891ec79fcfd216b01f20420a1cb03f30a2c49f89..52f199d90bf34c97e861f255cf1fca80c2d6551e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-04-20 Marek Polacek <polacek@redhat.com> + + PR c++/94505 - bogus -Wparentheses warning with fold-expression. + * pt.c (fold_expression): Add warning_sentinel for -Wparentheses + before calling build_x_binary_op. + 2020-04-20 Marek Polacek <polacek@redhat.com> * coroutines.cc (captures_temporary): Don't assign the result of diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4f4c04e7df8961dcc4e0c826724c66f6f49e6f90..899df9a330cf67c63c42b3c2d2a57a448f3737cb 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12379,6 +12379,7 @@ fold_expression (tree t, tree left, tree right, tsubst_flags_t complain) if (FOLD_EXPR_MODIFY_P (t)) return build_x_modify_expr (input_location, left, code, right, complain); + warning_sentinel s(warn_parentheses); switch (code) { case COMPOUND_EXPR: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce31ed0cd448dff98fc8f03d6ab2990ba08edc7b..33f008b9af432b0773694cb9d31c76a744b41dd2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-20 Marek Polacek <polacek@redhat.com> + + PR c++/94505 - bogus -Wparentheses warning with fold-expression. + * g++.dg/cpp1z/fold11.C: New test. + 2020-04-20 Andreas Krebbel <krebbel@linux.ibm.com> * g++.dg/pr94666.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/fold11.C b/gcc/testsuite/g++.dg/cpp1z/fold11.C new file mode 100644 index 0000000000000000000000000000000000000000..09a30555eee73085968c0917efb98cfafbcddd7d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/fold11.C @@ -0,0 +1,12 @@ +// PR c++/94505 - bogus -Wparentheses warning with fold-expression. +// { dg-do compile { target c++17 } } +// { dg-options "-Wparentheses" } + +template <bool... B> +bool foo () { + return ((B && true) || ...); // { dg-bogus "suggest parentheses" } +} + +int main () { + foo<true, false, false, true> (); +}