c++: ICE with bogus late return type [PR99803]
commit70f2bff43aadd2fcc0595bf9f4bab72647529655
authorMarek Polacek <polacek@redhat.com>
Wed, 14 Apr 2021 21:57:15 +0000 (14 17:57 -0400)
committerMarek Polacek <polacek@redhat.com>
Fri, 16 Apr 2021 14:58:52 +0000 (16 10:58 -0400)
treef2beeb4a289650d3fa2f2a4894da3bdb6d2a9448
parenteb8c931e0dbf1d7d9bc1279cab68a963e8f3c299
c++: ICE with bogus late return type [PR99803]

Here we ICE when compiling this code in C++20, because we're trying to
slam a 'typename' after the ->.  The cp_parser_template_id call just
before the spot I'm changing parsed A::template A<int> as a BASELINK
that contains a constructor, but make_typename_type crashes on that.

This patch makes make_typename_type more robust instead of checking
for is_overloaded_fn prior calling it.

gcc/cp/ChangeLog:

PR c++/99803
* decl.c (make_typename_type): Give an error and return when
name is is_overloaded_fn.
* parser.c (cp_parser_class_name): Don't check is_overloaded_fn
before calling make_typename_type.

gcc/testsuite/ChangeLog:

PR c++/99803
* g++.dg/cpp2a/typename14.C: Don't expect particular error
messages.
* g++.dg/cpp2a/typename19.C: New test.
gcc/cp/decl.c
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp2a/typename14.C
gcc/testsuite/g++.dg/cpp2a/typename19.C [new file with mode: 0644]