Fix crash70.C with -std=c++1z.
authorJason Merrill <jason@redhat.com>
Mon, 7 Dec 2015 04:35:02 +0000 (23:35 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 7 Dec 2015 04:35:02 +0000 (23:35 -0500)
* semantics.c (finish_qualified_id_expr): Handle
UNBOUND_CLASS_TEMPLATE.

From-SVN: r231352

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/g++.dg/template/crash70.C

index 1fdbe05..9a8a2b5 100644 (file)
@@ -1,5 +1,8 @@
 2015-12-06  Jason Merrill  <jason@redhat.com>
 
+       * 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
index 82f7d3a..80d1b10 100644 (file)
@@ -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.  */
index 742f77b..9ccadfb 100644 (file)
@@ -2,6 +2,6 @@
 
 template<int> struct A;
 
-template<typename T> void foo (A<&T::template i>); // { dg-error "not a template" }
+template<typename T> void foo (A<&T::template i>);
 
 template void foo<A<0> > (A<0>); // { dg-error "does not match" }