Commit a4cc2828 by Jason Merrill Committed by Jason Merrill

class.c (resolves_to_fixed_type_p): Check CLASSTYPE_FINAL.

	* class.c (resolves_to_fixed_type_p): Check CLASSTYPE_FINAL.

If we have a pointer to final class, we know the dynamic type of the object
must be that class, because it can't have any derived classes.

From-SVN: r272656
parent 27bb6f7c
2019-06-25 Jason Merrill <jason@redhat.com>
* class.c (resolves_to_fixed_type_p): Check CLASSTYPE_FINAL.
2019-06-25 Jakub Jelinek <jakub@redhat.com> 2019-06-25 Jakub Jelinek <jakub@redhat.com>
PR c++/90969 PR c++/90969
......
...@@ -7477,10 +7477,12 @@ resolves_to_fixed_type_p (tree instance, int* nonnull) ...@@ -7477,10 +7477,12 @@ resolves_to_fixed_type_p (tree instance, int* nonnull)
} }
fixed = fixed_type_or_null (instance, nonnull, &cdtorp); fixed = fixed_type_or_null (instance, nonnull, &cdtorp);
if (fixed == NULL_TREE)
return 0;
if (INDIRECT_TYPE_P (t)) if (INDIRECT_TYPE_P (t))
t = TREE_TYPE (t); t = TREE_TYPE (t);
if (CLASS_TYPE_P (t) && CLASSTYPE_FINAL (t))
return 1;
if (fixed == NULL_TREE)
return 0;
if (!same_type_ignoring_top_level_qualifiers_p (t, fixed)) if (!same_type_ignoring_top_level_qualifiers_p (t, fixed))
return 0; return 0;
return cdtorp ? -1 : 1; return cdtorp ? -1 : 1;
......
// { dg-do compile { target c++11 } }
// { dg-additional-options -fdump-tree-gimple }
// { dg-final { scan-tree-dump-not "vptr" gimple } }
struct A { int i; };
struct B final: public virtual A { int j; };
int f(B* b) { return b->i; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment