Commit d168b3da by Jason Merrill Committed by Jason Merrill

PR c++/68377 - parenthesized expr in fold-expression

	* parser.c (cp_parser_fold_expression): Check TREE_NO_WARNING.

From-SVN: r242561
parent 77b384c5
2016-11-17 Jason Merrill <jason@redhat.com>
PR c++/68377
* parser.c (cp_parser_fold_expression): Check TREE_NO_WARNING.
2016-11-16 Jason Merrill <jason@redhat.com> 2016-11-16 Jason Merrill <jason@redhat.com>
PR c++/78373 PR c++/78373
......
...@@ -4679,7 +4679,9 @@ cp_parser_fold_expression (cp_parser *parser, tree expr1) ...@@ -4679,7 +4679,9 @@ cp_parser_fold_expression (cp_parser *parser, tree expr1)
/* The operands of a fold-expression are cast-expressions, so binary or /* The operands of a fold-expression are cast-expressions, so binary or
conditional expressions are not allowed. We check this here to avoid conditional expressions are not allowed. We check this here to avoid
tentative parsing. */ tentative parsing. */
if (is_binary_op (TREE_CODE (expr1))) if (EXPR_P (expr1) && TREE_NO_WARNING (expr1))
/* OK, the expression was parenthesized. */;
else if (is_binary_op (TREE_CODE (expr1)))
error_at (location_of (expr1), error_at (location_of (expr1),
"binary expression in operand of fold-expression"); "binary expression in operand of fold-expression");
else if (TREE_CODE (expr1) == COND_EXPR) else if (TREE_CODE (expr1) == COND_EXPR)
// PR c++/68377
// { dg-options -std=c++1z }
struct Sink { } s;
template <class T> Sink& operator<<(Sink&, const T&);
template<class... Tx>
int f(Tx... xs) {
return ((xs+1) + ...);
}
int main() {
s << f(3,4,5) << "\n";
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment