aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-05-23 17:04:56 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-05-23 17:04:56 +0000
commit6131102ce3f1ac19a9c6637827b1f4dff9eea97b (patch)
treeedabca55a819f56695f04ed2eceaf24350dafd87
parent1b4b1fc7cab09c63681cd4deeddcb81a4ee90d1b (diff)
downloadgcc-6131102ce3f1ac19a9c6637827b1f4dff9eea97b.zip
gcc-6131102ce3f1ac19a9c6637827b1f4dff9eea97b.tar.gz
gcc-6131102ce3f1ac19a9c6637827b1f4dff9eea97b.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/parser.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/pr80866.C10
4 files changed, 24 insertions, 0 deletions
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 <nathan@acm.org>
+ 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<struct tree_check> ();
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 <nathan@acm.org>
+
+ PR c++/80866
+ * g++.dg/parse/pr80866.C: New.
+
2017-05-23 Jan Hubicka <hubicka@ucw.cz>
* 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 <typename T> void pow(T);
+}
+using namespace math;
+
+decltype(pow<>(0)) z();