From: Nathan Sidwell Date: Tue, 23 May 2017 17:04:56 +0000 (+0000) Subject: re PR c++/80866 (segfault in is_overloaded_fn()) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6131102ce3f1ac19a9c6637827b1f4dff9eea97b;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2e2415c130e..254f5b7cb72 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 b39e624734b..71e1d166eac 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 e5d4fce0dbe..f536dda0fda 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 00000000000..18543baba19 --- /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();