Bug 27331 - Data member offset change not considered local

The comparison code fails to consider that a data member which offset
changed (and which type didn't change) constitutes a local change of
the enclosing class type.

Fixed thus.

	* src/abg-ir.cc (equals): In the overload of class_or_union, when
	a data member changes without having its type change, then
	consider the data change as being local.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-3.txt:
	Adjust.
	* tests/data/test-diff-filter/test-PR27331-report-0.txt: New
	reference output.
	* tests/data/test-diff-filter/test-PR27331-v{0,1}.c: New test
	source files.
	* tests/data/test-diff-filter/test-PR27331-v{0,1}.o: New test
	binary inputs.
	* tests/data/Makefile.am: Add these new test material to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the tests above to
	the harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2021-02-03 13:47:46 +01:00
parent 271e3afaf6
commit 013a19c5fe
9 changed files with 33 additions and 3 deletions

View File

@ -19732,7 +19732,8 @@ equals(const class_or_union& l, const class_or_union& r, change_kind* k)
{
// Report any representation change as being local.
if (!types_have_similar_structure((*d0)->get_type(),
(*d1)->get_type()))
(*d1)->get_type())
|| (*d0)->get_type() == (*d1)->get_type())
*k |= LOCAL_TYPE_CHANGE_KIND;
else
*k |= SUBTYPE_CHANGE_KIND;

View File

@ -919,6 +919,11 @@ test-diff-filter/test-PR26684-dwarf5.o \
test-diff-filter/test-PR26684-dwarf4.o \
test-diff-filter/test-PR26684.c \
test-diff-filter/test-PR26684-report-0.txt \
test-diff-filter/test-PR27331-v0.c \
test-diff-filter/test-PR27331-v0.o \
test-diff-filter/test-PR27331-v1.c \
test-diff-filter/test-PR27331-v1.o \
test-diff-filter/test-PR27331-report-0.txt \
\
test-diff-suppr/test0-type-suppr-v0.cc \
test-diff-suppr/test0-type-suppr-v1.cc \

View File

@ -0,0 +1,9 @@
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 1 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
'struct S at test-PR27331-v0.c:1:1' changed:
type size hasn't changed
there are data member changes:
'int S::var' offset changed from 0 to 1 (in bits) (by +1 bits)

View File

@ -0,0 +1,4 @@
struct S {
int var : 1;
};
int fun(struct S s) { return s.var; }

Binary file not shown.

View File

@ -0,0 +1,4 @@
struct S {
int : 1, var : 1;
};
int fun(struct S s) { return s.var; }

Binary file not shown.

View File

@ -1,6 +1,6 @@
================ changes of 'libspice-server.so.1.8.0'===============
Leaf changes summary: 10 artifacts changed (10 filtered out)
Changed leaf types summary: 1 (10 filtered out) leaf types changed
Leaf changes summary: 10 artifacts changed (13 filtered out)
Changed leaf types summary: 1 (13 filtered out) leaf types changed
Removed/Changed/Added functions summary: 1 Removed, 0 Changed, 8 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

View File

@ -780,6 +780,13 @@ InOutSpec in_out_specs[] =
"data/test-diff-filter/test-PR26684-report-0.txt",
"output/test-diff-filter/test-PR26684-report-0.txt",
},
{
"data/test-diff-filter/test-PR27331-v0.o",
"data/test-diff-filter/test-PR27331-v1.o",
"--no-default-suppression --leaf-changes-only",
"data/test-diff-filter/test-PR27331-report-0.txt",
"output/test-diff-filter/test-PR27331-report-0.txt",
},
// This should be the last entry
{NULL, NULL, NULL, NULL, NULL}
};