c++: Fix ICE-on-invalid with lambda template [PR94507]
authorMarek Polacek <polacek@redhat.com>
Mon, 6 Apr 2020 23:59:04 +0000 (19:59 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 8 Apr 2020 17:37:39 +0000 (13:37 -0400)
commit77d6dfc929832a542a25fc455b90f1a4bc83229c
tree06e89b6487e72df9ce0862a3d50e30dc43904da8
parentdd9ca9d770a18ce4b16d867f49fef3293b483ff5
c++: Fix ICE-on-invalid with lambda template [PR94507]

While reducing something else I noticed that we ICE on the following
invalid code.  In tsubst_lambda_expr, tsubst_template_decl has already
reported an error and returned the error_mark_node, so make sure we
don't ICE on that.  I'm using a goto here because we still have to
do finish_struct because it does popclass ().

PR c++/94507 - ICE-on-invalid with lambda template.
* pt.c (tsubst_lambda_expr): Cope when tsubst_template_decl or
tsubst_function_decl returns error_mark_node.

* g++.dg/cpp2a/lambda-generic7.C: New test.
gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/lambda-generic7.C [new file with mode: 0644]