This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unreviewed C++ patches


On Mon, May 16, 2005 at 11:19:47PM -0700, Mark Mitchell wrote:
> On the other hand, I have no idea what the current code is trying to do; 
> the comment:
> 
>   /* Avoid trying to get an operand off an identifier node.  */
> 
> doesn't look like something I would have written, though you never know. 
>  How about just replacing the entire contents of the "if (decl_context 
> == FIELD)" block with:
> 
>   if (declarator && declarator->kind == cdk_id)
>     error ("invalid storage class specified for data member %qD",
>            declarator->u.id.unqualified_name);
>   else
>     error ("invalid storage class specified for data member");
>   return error_mark_node;
> 
> ?

This would report the name only for some fields, eventhough the name
is known.  NAME is guaranteed to be non-NULL, so all the code is trying
to do is categorize what NAME actually is.
So error ("storage class specified for %qs", name); is certainly a good
fallback, or ...for field %qs.
So, IMHO either we can use e.g.:

if (decl_context == FIELD)
  error ("storage class specified for field %qs", name);
else
...

or

if (decl_context == FIELD)
  error ("storage class specified for declaration %qs", name);
else
...

or

if (decl_context == FIELD)
  {
    int op;
    op = (id_declarator != NULL
	  && IDENTIFIER_OPNAME_P (id_declarator->u.id.unqualified_name));
    error ("storage class specified for %s %qs",
	   op ? "member operator" : "field", name);
  }
else
...

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]