We issue bogus -Wparentheses warnings (3 of them!) for this fold expression:
((B && true) || ...)
Firstly, issuing a warning for a compiler-generated expression is wrong
and secondly, B && true must be wrapped in ( ) otherwise you'll get
error: binary expression in operand of fold-expression.
PR c++/94505 - bogus -Wparentheses warning with fold-expression.
* pt.c (fold_expression): Add warning_sentinel for -Wparentheses
before calling build_x_binary_op.
* g++.dg/cpp1z/fold11.C: New test.
+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
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:
+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.
--- /dev/null
+// 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> ();
+}