Message ID | 52C6F365.4040700@oracle.com |
---|---|
State | New |
Headers | show |
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. > + issued. If the base in incomplete, then NULL_TREE is returned. */ "If T is incomplete" Jason
On 01/03/2014 01:47 PM, Jason Merrill wrote: >> + issued. If the base in incomplete, then NULL_TREE is returned. */ > > "If T is incomplete" "...even if BASE is the same type." Jason
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 ;)
Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 206313) +++ cp/cp-tree.h (working copy) @@ -1324,7 +1324,9 @@ enum languages { lang_c, lang_cplusplus, lang_java /* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and ambiguity issues. */ #define DERIVED_FROM_P(PARENT, TYPE) \ - (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)))) /* Gives the visibility specification for a class type. */ #define CLASSTYPE_VISIBILITY(TYPE) \ Index: cp/search.c =================================================================== --- cp/search.c (revision 206313) +++ cp/search.c (working copy) @@ -177,8 +177,8 @@ accessible_base_p (tree t, tree base, bool conside discovered. If the base is inaccessible, or ambiguous, then error_mark_node is - returned. If the tf_error bit of COMPLAIN is not set, no error - is issued. */ + returned. If the tf_error bit of COMPLAIN is not set, no error is + issued. If the base in incomplete, then NULL_TREE is returned. */ tree lookup_base (tree t, tree base, base_access access, Index: testsuite/g++.dg/ext/is_base_of_incomplete-2.C =================================================================== --- testsuite/g++.dg/ext/is_base_of_incomplete-2.C (revision 0) +++ testsuite/g++.dg/ext/is_base_of_incomplete-2.C (working copy) @@ -0,0 +1,5 @@ +struct T; + +int check1[__is_base_of(T, T) ? 1 : -1]; +int check2[__is_base_of(T, const T) ? 1 : -1]; +int check3[__is_base_of(volatile T, T) ? 1 : -1];