Hi,

the primary issue here is a rather straightforward error-recovery, where, after a sensible (but see below) error message we ICE in get_underlying_template - called by convert_template_argument - because we don't handle correctly error_mark_node as TREE_TYPE, as set in grokdeclarator. While working on it I noticed that the error message emitted by grokdeclarator seems suboptimal, because, per 10.1.3/2, we correctly handle the alias declaration like a typedef but, I believe, we don't want to just say *typedef* in the error message: luckily the infrastructure to be more accurate is fully available, because we need it to set TYPE_DECL_ALIAS_P anyway.

Tested x86_64-linux.

Thanks, Paolo.

//////////////////////

/cp
2018-09-28  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84423
        * pt.c (convert_template_argument): Immediately return error_mark_node
        if the second argument is erroneous.
        * decl.c (grokdeclarator): Improve error message for 'auto' in
        alias declaration.

/testsuite
2018-09-28  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/84423
        * g++.dg/concepts/pr84423.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 264687)
+++ cp/decl.c   (working copy)
@@ -11879,6 +11879,7 @@ grokdeclarator (const cp_declarator *declarator,
   /* If this is declaring a typedef name, return a TYPE_DECL.  */
   if (typedef_p && decl_context != TYPENAME)
     {
+      bool alias_p = decl_spec_seq_has_spec_p (declspecs, ds_alias);
       tree decl;
 
       /* This declaration:
@@ -11901,7 +11902,10 @@ grokdeclarator (const cp_declarator *declarator,
 
       if (type_uses_auto (type))
        {
-         error ("typedef declared %<auto%>");
+         if (alias_p)
+           error ("%<auto%> not allowed in alias declaration");
+         else
+           error ("typedef declared %<auto%>");
          type = error_mark_node;
        }
 
@@ -11961,7 +11965,7 @@ grokdeclarator (const cp_declarator *declarator,
                      inlinep, friendp, raises != NULL_TREE,
                      declspecs->locations);
 
-      if (decl_spec_seq_has_spec_p (declspecs, ds_alias))
+      if (alias_p)
        /* Acknowledge that this was written:
             `using analias = atype;'.  */
        TYPE_DECL_ALIAS_P (decl) = 1;
Index: cp/pt.c
===================================================================
--- cp/pt.c     (revision 264687)
+++ cp/pt.c     (working copy)
@@ -7776,7 +7776,7 @@ convert_template_argument (tree parm,
   tree val;
   int is_type, requires_type, is_tmpl_type, requires_tmpl_type;
 
-  if (parm == error_mark_node)
+  if (parm == error_mark_node || error_operand_p (arg))
     return error_mark_node;
 
   /* Trivially convert placeholders. */
Index: testsuite/g++.dg/concepts/pr84423.C
===================================================================
--- testsuite/g++.dg/concepts/pr84423.C (nonexistent)
+++ testsuite/g++.dg/concepts/pr84423.C (working copy)
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fconcepts" }
+
+template<typename> using A = auto;  // { dg-error "alias declaration" }
+
+template<template<typename> class> struct B {};
+
+B<A> b;

Reply via email to