[C++ patch] for c++/37140

Fabien Chêne fabien.chene@gmail.com
Fri Jan 31 14:43:00 GMT 2014


2014-01-28 Jason Merrill <jason@redhat.com>:
> On 01/27/2014 04:28 PM, Fabien Chêne wrote:
>>
>> +  if (DECL_DEPENDENT_P (decl) && USING_DECL_TYPENAME_P (decl))
>> +    {
>> +      /* We have found a type introduced by a using
>> +        declaration at class scope that refers to a dependent
>> +        type.
>> +
>> +        using typename :: [opt] nested-name-specifier unqualified-id ;
>> +      */
>> +      decl = make_typename_type (TREE_TYPE (decl),
>> +                                DECL_NAME (decl),
>> +                                typename_type, tf_error);
>> +      if (decl != error_mark_node)
>> +       decl = TYPE_NAME (decl);
>> +
>> +      return decl;
>> +    }
>> +
>>     while (TREE_CODE (decl) == USING_DECL && !DECL_DEPENDENT_P (decl))
>>       decl = USING_DECL_DECLS (decl);
>
>
> Shouldn't the new code be after the while loop?

Actually, as a non-dependent USING_DECL may refer to a dependent one,
that would make sense.
I have failed however to find a testcase where the code above does not
work, probably because as in the example below, a non-dependent
USING_DECL refering to a dependent one implicitly requires the base
class to be parsed before, so that the instanciation can be performed.
Thus, the typename_type is already created.

template <class> struct B
{
  typedef char type;
};

template <class T> struct C : B<T>
{
  using typename B<T>::type;
};

struct D : C<int>
{
  using C<int>::type;
  type z;
};

Anyway, your suggestion makes sense to me, and I have successfully
tested the attached patch on x86_64 linux.


2014-01-31  Fabien Chêne  <fabien@gcc.gnu.org>
        PR c++/37140
        * parser.c (cp_parser_nonclass_name): Call strip_using_decl and
    move the code handling dependent USING_DECLs...
        * name-lookup.c (strip_using_decl): ...Here.

2014-01-31  Fabien Chêne  <fabien@gcc.gnu.org>

        PR c++/37140
        * g++.dg/template/using27.C: New.
        * g++.dg/template/using28.C: New.
        * g++.dg/template/using29.C: New.

-- 
Fabien
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr37140_2.patch
Type: text/x-diff
Size: 4101 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140131/62b91355/attachment.bin>


More information about the Gcc-patches mailing list