aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2021-04-14 17:57:15 -0400
committerMarek Polacek <polacek@redhat.com>2021-04-16 10:58:52 -0400
commit70f2bff43aadd2fcc0595bf9f4bab72647529655 (patch)
treef2beeb4a289650d3fa2f2a4894da3bdb6d2a9448 /gcc/cp/decl.c
parenteb8c931e0dbf1d7d9bc1279cab68a963e8f3c299 (diff)
downloadgcc-70f2bff43aadd2fcc0595bf9f4bab72647529655.zip
gcc-70f2bff43aadd2fcc0595bf9f4bab72647529655.tar.gz
gcc-70f2bff43aadd2fcc0595bf9f4bab72647529655.tar.bz2
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.
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d40b7a7..942eb31 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4055,6 +4055,12 @@ make_typename_type (tree context, tree name, enum tag_types tag_type,
error ("%qD used without template arguments", name);
return error_mark_node;
}
+ else if (is_overloaded_fn (name))
+ {
+ if (complain & tf_error)
+ error ("%qD is a function, not a type", name);
+ return error_mark_node;
+ }
gcc_assert (identifier_p (name));
gcc_assert (TYPE_P (context));
@@ -4066,7 +4072,7 @@ make_typename_type (tree context, tree name, enum tag_types tag_type,
error ("%q#T is not a class", context);
return error_mark_node;
}
-
+
/* When the CONTEXT is a dependent type, NAME could refer to a
dependent base class of CONTEXT. But look inside it anyway
if CONTEXT is a currently open scope, in case it refers to a