c++: GCC accepts junk before fold-expression [PR86773]
Here we accept a bogus expression before a left fold:
Recall that a fold expression looks like:
fold-expression:
( cast-expression fold-operator ... )
( ... fold-operator cast-expression )
( cast-expression fold-operator ... fold-operator cast-expression )
but here we have
( cast-expression ... fold-operator cast-expression )
The best fix seems to just return error_mark_node when we know this code
is invalid, and let the subsequent code report that a ) was expected.
gcc/cp/ChangeLog:
PR c++/86773
* parser.c (cp_parser_fold_expression): Return error_mark_node
if a left fold is preceded by an expression.
gcc/testsuite/ChangeLog:
PR c++/86773
* g++.dg/cpp1z/fold12.C: New test.