From 6131102ce3f1ac19a9c6637827b1f4dff9eea97b Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 23 May 2017 17:04:56 +0000 Subject: [PATCH] re PR c++/80866 (segfault in is_overloaded_fn()) PR c++/80866 * parser.c (cp_parser_template_id): Keep the lookup when stashing the template_id. PR c++/80866 * g++.dg/parse/pr80866.C: New. From-SVN: r248377 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/parser.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/pr80866.C | 10 ++++++++++ 4 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/g++.dg/parse/pr80866.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2e2415c..254f5b7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-05-23 Nathan Sidwell + PR c++/80866 + * parser.c (cp_parser_template_id): Keep the lookup when stashing + the template_id. + * cp-tree.h (DECL_HIDDEN_P): New. * name-lookup.c (set_decl_context, set_local_extern_decl_linkage): New, broken out of ... diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b39e624..71e1d16 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15570,6 +15570,11 @@ cp_parser_template_id (cp_parser *parser, = make_location (token->location, token->location, finish_loc); token->location = combined_loc; + /* We must mark the lookup as kept, so we don't throw it away on + the first parse. */ + if (is_overloaded_fn (template_id)) + lookup_keep (get_fns (template_id), true); + /* Retrieve any deferred checks. Do not pop this access checks yet so the memory will not be reclaimed during token replacing below. */ token->u.tree_check_value = ggc_cleared_alloc (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e5d4fce..f536dda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-23 Nathan Sidwell + + PR c++/80866 + * g++.dg/parse/pr80866.C: New. + 2017-05-23 Jan Hubicka * gcc.dg/ipa/ctor-empty-1.c: Update template. diff --git a/gcc/testsuite/g++.dg/parse/pr80866.C b/gcc/testsuite/g++.dg/parse/pr80866.C new file mode 100644 index 0000000..18543ba --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr80866.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } +// PR 80866 recycled a lookup too soon. + +void pow(); +namespace math { + template void pow(T); +} +using namespace math; + +decltype(pow<>(0)) z(); -- 2.7.4