Fix inheritance of scope_decl::insert_member_decl

The classes class_decl, class_or_union and scope_decl derive from each
other. The method insert_member_decl is declared virtual and defined
in each of these. Unfortunately, it has different argument types in
the base scope_decl class.

Most calls to insert_member_decl are at a statically known class, but
in insert_decl_into_scope the method is called via a scope_decl
pointer. There is the possibility that this could be a type derived
from scope_decl rather than scope_decl itself, in which case the base
method would be called, not as intended.

This commit adjusts the type of the member argument to
scope_decl::insert_member_decl to match the other two classes and
eliminates the last trigger of Clang's -Werror-overloaded-virtual.

	* include/abg-ir.h (scope_decl::insert_member_decl): Change
	type of member argument from const decl_base_sptr& to plain
	decl_base_sptr.
	* src/abg-ir.cc (scope_decl::insert_member_decl): Likewise.

Signed-off-by: Giuliano Procida <gprocida@google.com>
This commit is contained in:
Giuliano Procida 2020-07-09 19:22:49 +01:00 committed by Dodji Seketeli
parent 38b1476765
commit 23f11d70de
2 changed files with 2 additions and 3 deletions

View File

@ -1674,8 +1674,7 @@ protected:
add_member_decl(const decl_base_sptr& member);
virtual decl_base_sptr
insert_member_decl(const decl_base_sptr& member,
declarations::iterator before);
insert_member_decl(decl_base_sptr member, declarations::iterator before);
virtual void
remove_member_decl(decl_base_sptr member);

View File

@ -6162,7 +6162,7 @@ scope_decl::add_member_decl(const decl_base_sptr& member)
/// @param before an interator pointing to the element before which
/// the new member should be inserted.
decl_base_sptr
scope_decl::insert_member_decl(const decl_base_sptr& member,
scope_decl::insert_member_decl(decl_base_sptr member,
declarations::iterator before)
{
ABG_ASSERT(!member->get_scope());