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 1fdbe05c5f7397458eb851d62eccfe0774de58f3..9a8a2b58b04643b3d559bed56093db56e78ffbc8 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 82f7d3a2c5ed8ea5ca10319604ade1025d81b106..80d1b10ddad321feae86451aebdebc9cf0687b4e 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 742f77b222522385f8cb4bd76fa97fac32e58036..9ccadfb6fadbb04cbe20433663537ba86a681a1a 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" }