aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2022-04-29 15:01:12 -0400
committerMarek Polacek <polacek@redhat.com>2022-05-04 16:06:02 -0400
commita733dea9e7c39352ce9f72059938833eaa819467 (patch)
treeccbeda72833e32500b8619ca0db65eea7c174725 /libcpp
parentc8df7208864d863f58da55d42ff82663059930b1 (diff)
downloadgcc-a733dea9e7c39352ce9f72059938833eaa819467.zip
gcc-a733dea9e7c39352ce9f72059938833eaa819467.tar.gz
gcc-a733dea9e7c39352ce9f72059938833eaa819467.tar.bz2
c++: wrong parse with functors [PR64679]
Consider struct F { F(int) {} F operator()(int) const { return *this; } }; and F(i)(0)(0); where we're supposed to first call the constructor and then invoke the operator() twice. However, we parse this as an init-declarator: "(i)" looks like a perfectly valid declarator, then we see an '(' and think it must be an initializer, so we commit and we're toast. My fix is to look a little bit farther before deciding we've seen an initializer. This is only a half of c++/64679, the other part of the PR is unrelated: there the problem is that we are calling pushdecl while parsing tentatively (in cp_parser_parameter_declaration_list), which is bad. PR c++/64679 gcc/cp/ChangeLog: * parser.cc (cp_parser_init_declarator): Properly handle a series of operator() calls, they are not part of an init-declarator. gcc/testsuite/ChangeLog: * g++.dg/parse/functor1.C: New test.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions