[PATCH 2/3] Fix inheritance of scope_decl::insert_member_decl
Thu Jul 9 18:22:49 GMT 2020
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
* src/abg-ir.cc (scope_decl::insert_member_decl): Likewise.
Signed-off-by: Giuliano Procida <firstname.lastname@example.org>
include/abg-ir.h | 3 +--
src/abg-ir.cc | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/abg-ir.h b/include/abg-ir.h
index c2b66c4c..ea6a7ce4 100644
@@ -1653,8 +1653,7 @@ protected:
add_member_decl(const decl_base_sptr& member);
- insert_member_decl(const decl_base_sptr& member,
- declarations::iterator before);
+ insert_member_decl(decl_base_sptr member, declarations::iterator before);
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index a434ec69..a257cf67 100644
@@ -6081,7 +6081,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.
-scope_decl::insert_member_decl(const decl_base_sptr& member,
More information about the Libabigail