diff mbox

[C++] Fix __is_base_of vs incomplete types

Message ID 52BD6C6C.5080606@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 27, 2013, 12:02 p.m. UTC
Hi,

On 12/12/2013 03:19 PM, Jason Merrill wrote:
> I wouldn't expect it to cause problems.
Ok. Then I looked a bit into this and something is making me nervous: 
lookup_base wants to return a binfo, not a type. Thus what do we do when 
the type is incomplete and there is no binfo? Something like the below 
"works" but it doesn't seem right vs multiple call of the function with 
the same arguments. Conservatively but still more neatly than my first 
try, we could maybe use same_type_ignoring_top_level_qualifiers_p in the 
definition of the DERIVED_FROM_P macro?

Thanks,
Paolo.

////////////////

Comments

Jason Merrill Jan. 2, 2014, 9:46 p.m. UTC | #1
On 12/27/2013 07:02 AM, Paolo Carlini wrote:
> the same arguments. Conservatively but still more neatly than my first
> try, we could maybe use same_type_ignoring_top_level_qualifiers_p in the
> definition of the DERIVED_FROM_P macro?

Sure, let's do that.  And add something about incomplete types to the 
pre-function comment for lookup_base.

Jason
diff mbox

Patch

Index: search.c
===================================================================
--- search.c	(revision 206218)
+++ search.c	(working copy)
@@ -242,6 +242,12 @@  lookup_base (tree t, tree base, base_access access
       else
 	bk = bk_proper_base;
     }
+  else if (CLASS_TYPE_P (base) && same_type_p (TYPE_MAIN_VARIANT (t), base))
+    {
+      binfo = make_tree_binfo (0);
+      BINFO_TYPE (binfo) = base;
+      bk = bk_same_type;
+    }
   else
     {
       binfo = NULL_TREE;