[Patch] PR c++/26256

Fabien Chêne fabien.chene@gmail.com
Fri Jul 30 13:42:00 GMT 2010


Hi Jason, Hi All,

2010/6/18 Jason Merrill <jason@redhat.com>:
> On 06/16/2010 04:30 PM, Fabien Chêne wrote:
>>
>> @@ -2703,6 +2703,8 @@ count_fields (tree fields)
>>   int n_fields = 0;
>>   for (x = fields; x; x = TREE_CHAIN (x))
>>     {
>> +      if (TREE_CODE (x) == USING_DECL)
>> +       continue;
>> @@ -2720,6 +2722,9 @@ add_fields_to_record_type (tree fields,
>>   tree x;
>>   for (x = fields; x; x = TREE_CHAIN (x))
>>     {
>> +      if (TREE_CODE (x) == USING_DECL)
>> +       continue;
>
> I don't think we want to skip USING_DECLs here; we aren't only counting
> FIELD_DECLs, we count TYPE_DECLs and CONST_DECLs, too.

I will try to change that, but for now, it ICEs if we do not skip USING_DECLs.

I'm close to the result, but I'm not sure about how should behave the
compiler with the following examples.
I think that in both cases, the using declaration is invalid, can you
confirm that ?

struct H { typedef int type; };

struct I : H
{
  typedef int type; // { dg-message "local member" }
  using H::type; // { dg-error "invalid" }
};
struct I2 : H
{
  using H::type; // { dg-message "conflicting declaration" }
  typedef int type; // { dg-error "conflicts" }
};

Same question with 'struct type {} instead of 'typedef int type' ?

struct J { struct type {}; };

struct K : J
{
    struct type {}; // { dg-message "local member" }
    using J::type; // { dg-error "invalid" }
};

struct L : J
{
    using J::type; // { dg-message "conflicting declaration" }
    struct type {}; // { dg-error "conflicts" }
};

FYI, como rejects all using declarations and clang do not reject the
last one (using J::type in struct L)

Thanks,

-- 
Fabien



More information about the Gcc-patches mailing list