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: C++ Patch for c++/60894


2014-10-07 23:13 GMT+02:00 Jason Merrill <jason@redhat.com>:
> On 09/24/2014 05:15 PM, Jason Merrill wrote:
>>
>> On 09/24/2014 05:06 PM, Fabien Chêne wrote:
>>>
>>> Unfortunately, just stripping the USING_DECL in lookup_and_check_tag
>>> does not really work because some diagnotic codes expect the
>>> USING_DECL not to be stripped.
>
> It seems to me that the problem is that lookup_and_check_tag is rejecting a
> USING_DECL rather than returning it.  What if we return the USING_DECL?

If the USING_DECL is returned, the code below will be rejected as
expected, but the error message will not mention the line where the
USING_DECL appears as the previous definition, but at the target
declaration of the USING_DECL instead.

struct J
{
  struct type {};
};

struct L : J
{
  using J::type;
  struct type {};
};

The code doing that is in cp_parser_class_head, after the call to
xref_tag, at this point:

if (type != error_mark_node && COMPLETE_TYPE_P (type))
    {
      error_at (type_start_token->location, "redefinition of %q#T",
        type);
      error_at (type_start_token->location, "previous definition of %q+#T",
        type);
...

Actually, if xref_tag strips the USING_DECL, it finds a type already
complete and the original decl is lost for the diagnostic.
Trying to skip this error does not work because 'type' is really
expected not to be complete.
Hence, I guess the solution, however disgracious it could be,  is to
ignore USING_DECLS from cp_parser_class_head through xref_tag, and
wait for the appropriate diagnostic at finish_struct (in
supplement_binding more precisely).

-- 
Fabien


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