public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	       Nathan Sidwell <nathan@acm.org>
Subject: Re: [C++ Patch] PR 84423 ("[6/7/8/9 Regression] [concepts] ICE with invalid using declaration")
Date: Fri, 28 Sep 2018 20:26:00 -0000	[thread overview]
Message-ID: <b104f694-e139-ab3d-b1fd-f44d1bee4c25@oracle.com> (raw)
In-Reply-To: <CADzB+2kqCdAf679uR8iqP3RbHyzK3TtbUBn6Ah_7ZhF7hR++3w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

Hi,

On 9/28/18 7:18 PM, Jason Merrill wrote:
> On Fri, Sep 28, 2018 at 12:42 PM, Paolo Carlini
> <paolo.carlini@oracle.com> wrote:
>> 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.
> OK, though as long as you're messing with this error you might want to
> improve its location as well.

Thanks. About the location, you are certainly right, but doesn't seem 
trivial. Something we can do *now* is using 
declspecs->locations[ds_typedef] and declspecs->locations[ds_alias], but 
that gives us the location of the keyword 'typedef' and 'using', 
respectively, whereas I think that we would like to have the location of 
'auto' itself. I could look into that as a follow-up piece work (by the 
way, I'm always reluctant to embark in non trivial work having to do 
with locations because I suppose David is already on it?!?)

Paolo.

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


[-- Attachment #2: p --]
[-- Type: text/plain, Size: 2141 bytes --]

Index: constraint.cc
===================================================================
--- constraint.cc	(revision 264687)
+++ constraint.cc	(working copy)
@@ -1164,6 +1164,9 @@ build_constraints (tree tmpl_reqs, tree decl_reqs)
   if (!tmpl_reqs && !decl_reqs)
     return NULL_TREE;
 
+  //if (tmpl_reqs == error_mark_node || decl_reqs == error_mark_node)
+  //return NULL_TREE;
+
   tree_constraint_info* ci = build_constraint_info ();
   ci->template_reqs = tmpl_reqs;
   ci->declarator_reqs = decl_reqs;
Index: decl.c
===================================================================
--- decl.c	(revision 264687)
+++ 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,12 @@ grokdeclarator (const cp_declarator *declarator,
 
       if (type_uses_auto (type))
 	{
-	  error ("typedef declared %<auto%>");
+	  if (alias_p)
+	    error_at (declspecs->locations[ds_alias],
+		      "%<auto%> not allowed in alias declaration");
+	  else
+	    error_at (declspecs->locations[ds_typedef],
+		      "typedef declared %<auto%>");
 	  type = error_mark_node;
 	}
 
@@ -11961,7 +11967,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: pt.c
===================================================================
--- pt.c	(revision 264687)
+++ 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. */

  reply	other threads:[~2018-09-28 19:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 16:43 Paolo Carlini
2018-09-28 17:53 ` Jason Merrill
2018-09-28 20:26   ` Paolo Carlini [this message]
2018-09-29 20:14     ` Paolo Carlini
2018-10-09 11:37       ` [C++ Patch PING] " Paolo Carlini
2018-10-09 16:51       ` Jason Merrill
2018-10-09 19:27         ` Paolo Carlini
2018-10-09 20:34           ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b104f694-e139-ab3d-b1fd-f44d1bee4c25@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=nathan@acm.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).