ir: Support cloning data members of unions
authorDodji Seketeli <dodji@redhat.com>
Thu, 22 Sep 2022 13:26:10 +0000 (15:26 +0200)
committerDodji Seketeli <dodji@redhat.com>
Thu, 22 Sep 2022 13:26:10 +0000 (15:26 +0200)
When cloning a data member, var_decl::clone wrongly assumes we are
looking at a data member of a class.  It could also be a data member
of an union.  Fixed thus.

This fixes crashes when self comparing Fedora 36 packages of the qt6
group with the command:

    $ fedabipkgdiff --self-compare --from fc36 qt6-qtsensors

There are lot of other packages from the qt group that were making
this command fail, but I am not mentioning them here for the sake
conciseness.

* src/abg-ir.cc (var_decl::clone): Support cloning data members
for unions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-ir.cc

index 1cd2a219c5dcc97ab43008cc40831176f1319dc4..f739b12686997acea70e8b3597ef1104d960b6af 100644 (file)
@@ -19131,7 +19131,7 @@ var_decl::clone() const
 
   if (is_member_decl(*this))
     {
-      class_decl* scope = dynamic_cast<class_decl*>(get_scope());
+      class_or_union* scope = is_class_or_union_type(get_scope());
       scope->add_data_member(v, get_member_access_specifier(*this),
                             get_data_member_is_laid_out(*this),
                             get_member_is_static(*this),