[C++ Patch] Fix __is_base_of vs incomplete types

Paolo Carlini paolo.carlini@oracle.com
Fri Jan 3 22:50:00 GMT 2014


Hi,

On 01/03/2014 07:47 PM, Jason Merrill wrote:
> On 01/03/2014 12:29 PM, Paolo Carlini wrote:
>> -  (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_none) != NULL_TREE)
>> +  (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_none) != NULL_TREE \
>> +   || ((TYPE) && NON_UNION_CLASS_TYPE_P (TYPE) \
>> +       && same_type_ignoring_top_level_qualifiers_p ((PARENT), 
>> (TYPE))))
> Let's only check one or the other, depending on whether TYPE is 
> incomplete.
The dispatching seems tricky, though, because lookup_base has:

    if (!TYPE_P (t))
     {
       t_binfo = t;
       t = BINFO_TYPE (t);
     }
   else
     {
       t = complete_type (TYPE_MAIN_VARIANT (t));
       t_binfo = TYPE_BINFO (t);
     }

thus TYPE_P (t) isn't necessarily true and, more importantly, otherwise 
the function actively tries to complete the type. Do you think it can work?

Thanks,
Paolo.

PS: sorry about the sloppy comment in my last try ;)



More information about the Gcc-patches mailing list