From 5ea106d85b5e2e7278472070b45d22f892f1e1d3 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 6 Dec 2015 23:35:02 -0500 Subject: [PATCH] Fix crash70.C with -std=c++1z. * semantics.c (finish_qualified_id_expr): Handle UNBOUND_CLASS_TEMPLATE. From-SVN: r231352 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/semantics.c | 12 +++++++++++- gcc/testsuite/g++.dg/template/crash70.C | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1fdbe05c5f7..9a8a2b58b04 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2015-12-06 Jason Merrill + * semantics.c (finish_qualified_id_expr): Handle + UNBOUND_CLASS_TEMPLATE. + * parser.c (cp_parser_template_argument): Handle references in C++1z mode. * constexpr.c (potential_constant_expression_1): Don't error about diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 82f7d3a2c5e..80d1b10ddad 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1929,7 +1929,17 @@ finish_qualified_id_expr (tree qualifying_class, return error_mark_node; if (template_p) - check_template_keyword (expr); + { + if (TREE_CODE (expr) == UNBOUND_CLASS_TEMPLATE) + /* cp_parser_lookup_name thought we were looking for a type, + but we're actually looking for a declaration. */ + expr = build_qualified_name (/*type*/NULL_TREE, + TYPE_CONTEXT (expr), + TYPE_IDENTIFIER (expr), + /*template_p*/true); + else + check_template_keyword (expr); + } /* If EXPR occurs as the operand of '&', use special handling that permits a pointer-to-member. */ diff --git a/gcc/testsuite/g++.dg/template/crash70.C b/gcc/testsuite/g++.dg/template/crash70.C index 742f77b2225..9ccadfb6fad 100644 --- a/gcc/testsuite/g++.dg/template/crash70.C +++ b/gcc/testsuite/g++.dg/template/crash70.C @@ -2,6 +2,6 @@ template struct A; -template void foo (A<&T::template i>); // { dg-error "not a template" } +template void foo (A<&T::template i>); template void foo > (A<0>); // { dg-error "does not match" }