From a53a893b4fe04ec966a4ec178ee8f394426a5dad Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 1 Feb 2019 19:58:44 +0000 Subject: [PATCH] PR c++/88325 - ICE with invalid out-of-line template member definition. * parser.c (cp_parser_class_name): Don't call make_typename_type for overloads. * g++.dg/cpp2a/typename14.C: New test. From-SVN: r268455 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp2a/typename14.C | 25 +++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/typename14.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ca3618ee0601..f0545aee1168 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-02-01 Marek Polacek + + PR c++/88325 - ICE with invalid out-of-line template member definition. + * parser.c (cp_parser_class_name): Don't call make_typename_type + for overloads. + 2019-02-01 Jakub Jelinek PR c++/87175 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 91c5ff42fadb..ffecce4e29b2 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23167,7 +23167,9 @@ cp_parser_class_name (cp_parser *parser, decl = cp_parser_maybe_treat_template_as_class (decl, class_head_p); /* If this is a typename, create a TYPENAME_TYPE. */ - if (typename_p && decl != error_mark_node) + if (typename_p + && decl != error_mark_node + && !is_overloaded_fn (decl)) { decl = make_typename_type (scope, decl, typename_type, /*complain=*/tf_error); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cfcd4ce19bc6..1df9ba2674d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-01 Marek Polacek + + PR c++/88325 - ICE with invalid out-of-line template member definition. + * g++.dg/cpp2a/typename14.C: New test. + 2019-02-01 Richard Biener PR middle-end/88597 diff --git a/gcc/testsuite/g++.dg/cpp2a/typename14.C b/gcc/testsuite/g++.dg/cpp2a/typename14.C new file mode 100644 index 000000000000..4750db35cd84 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/typename14.C @@ -0,0 +1,25 @@ +// PR c++/88325 +// { dg-do compile { target c++2a } } + +template struct A +{ + template A (); +}; + +template +template +A::A () // { dg-error "partial specialization" } +{ +} + +template struct B +{ + template int foo (int); +}; + +template +template +B::foo(int) // { dg-error "partial specialization|declaration" } +{ + return 1; +} -- 2.43.5