PR30048 - wrong pretty representation of qualified pointers
authorDodji Seketeli <dodji@redhat.com>
Fri, 3 Feb 2023 00:15:41 +0000 (01:15 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 10 Feb 2023 12:15:27 +0000 (13:15 +0100)
A qualified type is textually represented as the following:

    <qualifier> <underlying-type>

were "qualifier" is the qualifier carried by the qualified type and
"underlying-type" is the type being qualified.

In this case, the qualifier prefixes the textual representation of the
qualified type.

This is true if the underlying type of the qualified type is a
non-const, non-reference type.  For instance:

    const int;

But when the underlying type is a pointer, then the qualified type is
represented as:

    int* const;

In that later case, the qualifier comes /after/ the textual
representation of the underlying type.

Now suppose the underlying type is itself a qualified type.  In that
case, for a non-const underlying type, we'd have, e.g:

    const volatile int;

where the qualifier precedes the qualified type (which is itself a
qualified type) /IF/ the ultimate underlying type (a.k.a the leaf
underlying type) is itself a non-const, non-reference type.

But if the ultimate underlying type is a pointer, a qualified type
with an underlying qualified type would be textually represented as,
e.g:

    int* const volatile;

In other words, if the leaf type is a pointer, the qualifier suffixes
the textual representation the underlying qualified type.

Libabigail is failing to apply this later rule.

As the type name is used as a key to cache IR nodes of DIEs (among
other things), getting it wrong can lead to a bumpy ride down the
road.

Fixed thus.

* src/abg-dwarf-reader.cc
(die_is_pointer_array_or_reference_type): Rename
die_is_pointer_or_reference_type into this.  This new name
reflects more what the function does as it tests if a DIE is for
pointer, an array or a reference.
(pointer_or_qual_die_of_anonymous_class_type): Adjust to use the
newly (and better) named die_is_pointer_array_or_reference_type.
(die_is_pointer_or_reference_type): Make this really test if a DIE
is for a pointer or a reference.  Now the name matches what the
function does.
(die_peel_qualified): Define new function.
(die_qualified_type_name): When a qualified name Q has another
qualified name as its underlying type, it's important to know if
the leaf type is a pointer type or not to know how to construct
the name of Q.  This change now peels the potential qualifiers
from the underlying type of the qualified type to see if the leaf
type is a pointer or not.
* src/abg-ir.cc (get_name_of_qualified_type): Likewise.  Also, the
name of array types doesn't follow the same rule as for pointers
and references.
* tests/data/test-abidiff-exit/PR30048-test-report-0.txt: Add new
reference test output.
* tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt:
Likewise.
* tests/data/test-abidiff-exit/PR30048-test-v{0,1}.c: Add source
code of binary input data.
* tests/data/test-abidiff-exit/PR30048-test-2-v{0,1}.cc: Likewise.
* tests/data/test-abidiff-exit/PR30048-test-v{0,1}.o: Add binary
input data.
* tests/data/test-abidiff-exit/PR30048-test-2-v{0,1}.o: Likewise.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-abidiff-exit.cc (in_out_specs): Add the input
binaries to this test harness.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
15 files changed:
src/abg-dwarf-reader.cc
src/abg-ir.cc
tests/data/Makefile.am
tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-2-v0.cc [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-2-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-2-v1.cc [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-2-v1.o [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-report-0.txt [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-v0.c [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-v0.o [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-v1.c [new file with mode: 0644]
tests/data/test-abidiff-exit/PR30048-test-v1.o [new file with mode: 0644]
tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt
tests/test-abidiff-exit.cc

index 92ce6c6a0b049d5f2806f56d2cb451e683eaf1dd..4fdd43909bdb7408cf1abd2515a0892c8f29094d 100644 (file)
@@ -424,6 +424,9 @@ pointer_or_qual_die_of_anonymous_class_type(const Dwarf_Die* die);
 static bool
 die_is_reference_type(const Dwarf_Die* die);
 
+static bool
+die_is_pointer_array_or_reference_type(const Dwarf_Die* die);
+
 static bool
 die_is_pointer_or_reference_type(const Dwarf_Die* die);
 
@@ -570,6 +573,9 @@ die_function_signature(const reader& rdr,
 static bool
 die_peel_qual_ptr(Dwarf_Die *die, Dwarf_Die& peeled_die);
 
+static bool
+die_peel_qualified(Dwarf_Die *die, Dwarf_Die& peeled_die);
+
 static bool
 die_function_type_is_method_type(const reader& rdr,
                                 const Dwarf_Die *die,
@@ -6868,7 +6874,7 @@ die_is_pointer_type(const Dwarf_Die* die)
 static bool
 pointer_or_qual_die_of_anonymous_class_type(const Dwarf_Die* die)
 {
-  if (!die_is_pointer_or_reference_type(die)
+  if (!die_is_pointer_array_or_reference_type(die)
       && !die_is_qualified_type(die))
     return false;
 
@@ -6926,11 +6932,20 @@ die_is_array_type(const Dwarf_Die* die)
 ///
 /// @return true iff @p die represents a pointer or reference type.
 static bool
-die_is_pointer_or_reference_type(const Dwarf_Die* die)
+die_is_pointer_array_or_reference_type(const Dwarf_Die* die)
 {return (die_is_pointer_type(die)
         || die_is_reference_type(die)
         || die_is_array_type(die));}
 
+/// Test if a DIE represents a pointer or a reference type.
+///
+/// @param die the die to consider.
+///
+/// @return true iff @p die represents a pointer or reference type.
+static bool
+die_is_pointer_or_reference_type(const Dwarf_Die* die)
+{return (die_is_pointer_type(die) || die_is_reference_type(die));}
+
 /// Test if a DIE represents a pointer, a reference or a typedef type.
 ///
 /// @param die the die to consider.
@@ -6939,7 +6954,7 @@ die_is_pointer_or_reference_type(const Dwarf_Die* die)
 /// typedef type.
 static bool
 die_is_pointer_reference_or_typedef_type(const Dwarf_Die* die)
-{return (die_is_pointer_or_reference_type(die)
+{return (die_is_pointer_array_or_reference_type(die)
         || dwarf_tag(const_cast<Dwarf_Die*>(die)) == DW_TAG_typedef);}
 
 /// Test if a DIE represents a class type.
@@ -7181,6 +7196,38 @@ die_peel_qual_ptr(Dwarf_Die *die, Dwarf_Die& peeled_die)
   return true;
 }
 
+/// Return the leaf object under a qualified type DIE.
+///
+/// @param die the DIE of the type to consider.
+///
+/// @param peeled_die out parameter.  Set to the DIE of the leaf
+/// object iff the function actually peeled anything.
+///
+/// @return true upon successful completion.
+static bool
+die_peel_qualified(Dwarf_Die *die, Dwarf_Die& peeled_die)
+{
+  if (!die)
+    return false;
+
+  memcpy(&peeled_die, die, sizeof(peeled_die));
+
+  int tag = dwarf_tag(&peeled_die);
+
+  bool result = false;
+  while (tag == DW_TAG_const_type
+        || tag == DW_TAG_volatile_type
+        || tag == DW_TAG_restrict_type)
+    {
+      if (!die_die_attribute(&peeled_die, DW_AT_type, peeled_die))
+       break;
+      tag = dwarf_tag(&peeled_die);
+      result = true;
+    }
+
+  return result;
+}
+
 /// Return the leaf object under a typedef type DIE.
 ///
 /// @param die the DIE of the type to consider.
@@ -9052,9 +9099,15 @@ die_qualified_type_name(const reader& rdr,
          repr.clear();
        else
          {
-           if (has_underlying_type_die
-               && die_is_pointer_or_reference_type(&underlying_type_die))
-             repr = underlying_type_repr + " " + repr;
+           if (has_underlying_type_die)
+             {
+               Dwarf_Die peeled;
+               die_peel_qualified(&underlying_type_die, peeled);
+               if (die_is_pointer_or_reference_type(&peeled))
+                 repr = underlying_type_repr + " " + repr;
+               else
+                 repr += " " + underlying_type_repr;
+             }
            else
              repr += " " + underlying_type_repr;
          }
index 4a598bde11d087b40faf022b2df38173644930b4..ff7573eafec7c97a07d56a63cabc37cde5b8f3e9 100644 (file)
@@ -8740,9 +8740,8 @@ get_name_of_qualified_type(const type_base_sptr& underlying_type,
 
   if (!quals_repr.empty())
     {
-      if (is_pointer_type(underlying_type)
-         || is_reference_type(underlying_type)
-         || is_array_type(underlying_type))
+      if (is_pointer_type(peel_qualified_type(underlying_type))
+         || is_reference_type(peel_qualified_type(underlying_type)))
        {
          name += " ";
          name += quals_repr;
index a4740e3ee65eb54ad8ea9a33a67978b31ba5bcfe..1a0a3fa461b9af87a2331ff099a9207e74e5aac5 100644 (file)
@@ -248,6 +248,16 @@ test-abidiff-exit/btf/test0-v0.c   \
 test-abidiff-exit/btf/test0-v0.o       \
 test-abidiff-exit/btf/test0-v1.c       \
 test-abidiff-exit/btf/test0-v1.o       \
+test-abidiff-exit/PR30048-test-report-0.txt \
+test-abidiff-exit/PR30048-test-v0.c \
+test-abidiff-exit/PR30048-test-v1.c \
+test-abidiff-exit/PR30048-test-v0.o \
+test-abidiff-exit/PR30048-test-v1.o \
+test-abidiff-exit/PR30048-test-2-report-1.txt \
+test-abidiff-exit/PR30048-test-2-v0.cc \
+test-abidiff-exit/PR30048-test-2-v0.o \
+test-abidiff-exit/PR30048-test-2-v1.cc \
+test-abidiff-exit/PR30048-test-2-v1.o \
 \
 test-diff-dwarf/test0-v0.cc            \
 test-diff-dwarf/test0-v0.o                     \
diff --git a/tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt b/tests/data/test-abidiff-exit/PR30048-test-2-report-1.txt
new file mode 100644 (file)
index 0000000..2650b5a
--- /dev/null
@@ -0,0 +1,136 @@
+Functions changes summary: 0 Removed, 7 Changed, 0 Added functions
+Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
+7 functions with some indirect sub-type change:
+
+  [C] 'function int[7]* N()' at PR30048-test-2-v0.cc:62:1 has some indirect sub-type changes:
+    return type changed:
+      entity changed from 'int[7]*' to 'int'
+      type size changed from 64 to 32 (in bits)
+
+  [C] 'function int* O()' at PR30048-test-2-v0.cc:64:1 has some indirect sub-type changes:
+    return type changed:
+      entity changed from 'int*' to 'int'
+      type size changed from 64 to 32 (in bits)
+
+  [C] 'function int ()* P()' at PR30048-test-2-v0.cc:67:1 has some indirect sub-type changes:
+    return type changed:
+      entity changed from 'int ()*' to 'int'
+      type size changed from 64 to 32 (in bits)
+
+  [C] 'function amusement* fun()' at PR30048-test-2-v0.cc:57:1 has some indirect sub-type changes:
+    return type changed:
+      in pointed to type 'struct amusement' at PR30048-test-2-v1.cc:1:1:
+        type size changed from 6528 to 768 (in bits)
+        24 data member changes:
+          type of 'int A[7]' changed:
+            entity changed from 'int[7]' to 'int'
+            type size changed from 224 to 32 (in bits)
+          type of 'int* B' changed:
+            entity changed from 'int*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 256 to 32 (in bits) (by -224 bits)
+          type of 'int ()* C' changed:
+            entity changed from 'int ()*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 320 to 64 (in bits) (by -256 bits)
+          type of 'int D[7][7]' changed:
+            entity changed from 'int[7][7]' to 'int'
+            type size changed from 1568 to 32 (in bits)
+          and offset changed from 384 to 96 (in bits) (by -288 bits)
+          type of 'int* E[7]' changed:
+            entity changed from 'int*[7]' to 'int'
+            type size changed from 448 to 32 (in bits)
+          and offset changed from 1984 to 128 (in bits) (by -1856 bits)
+          type of 'int ()* F[7]' changed:
+            entity changed from 'int ()*[7]' to 'int'
+            type size changed from 448 to 32 (in bits)
+          and offset changed from 2432 to 160 (in bits) (by -2272 bits)
+          type of 'int[7]* G' changed:
+            entity changed from 'int[7]*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 2880 to 192 (in bits) (by -2688 bits)
+          type of 'int** H' changed:
+            entity changed from 'int**' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 2944 to 224 (in bits) (by -2720 bits)
+          type of 'int ()* I' changed:
+            entity changed from 'int ()*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 3008 to 256 (in bits) (by -2752 bits)
+          type of 'int[7]* ()* J' changed:
+            entity changed from 'int[7]* ()*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 3072 to 288 (in bits) (by -2784 bits)
+          type of 'int* ()* K' changed:
+            entity changed from 'int* ()*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 3136 to 320 (in bits) (by -2816 bits)
+          type of 'int ()* ()* L' changed:
+            entity changed from 'int ()* ()*' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 3200 to 352 (in bits) (by -2848 bits)
+          type of 'volatile int a[7]' changed:
+            entity changed from 'volatile int[7]' to 'int'
+            type size changed from 224 to 32 (in bits)
+          and offset changed from 3264 to 384 (in bits) (by -2880 bits)
+          type of 'volatile int* const b' changed:
+            entity changed from 'volatile int* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 3520 to 416 (in bits) (by -3104 bits)
+          type of 'int ()* const c' changed:
+            entity changed from 'int ()* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 3584 to 448 (in bits) (by -3136 bits)
+          type of 'volatile int d[7][7]' changed:
+            entity changed from 'volatile int[7][7]' to 'int'
+            type size changed from 1568 to 32 (in bits)
+          and offset changed from 3648 to 480 (in bits) (by -3168 bits)
+          type of 'volatile int* const e[7]' changed:
+            entity changed from 'volatile int* const[7]' to 'int'
+            type size changed from 448 to 32 (in bits)
+          and offset changed from 5248 to 512 (in bits) (by -4736 bits)
+          type of 'int ()* const f[7]' changed:
+            entity changed from 'int ()* const[7]' to 'int'
+            type size changed from 448 to 32 (in bits)
+          and offset changed from 5696 to 544 (in bits) (by -5152 bits)
+          type of 'volatile int[7]* const g' changed:
+            entity changed from 'volatile int[7]* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 6144 to 576 (in bits) (by -5568 bits)
+          type of 'volatile int* const* const h' changed:
+            entity changed from 'volatile int* const* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 6208 to 608 (in bits) (by -5600 bits)
+          type of 'int ()* const i' changed:
+            entity changed from 'int ()* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 6272 to 640 (in bits) (by -5632 bits)
+          type of 'volatile int[7]* ()* const j' changed:
+            entity changed from 'volatile int[7]* ()* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 6336 to 672 (in bits) (by -5664 bits)
+          type of 'volatile int* ()* const k' changed:
+            entity changed from 'volatile int* ()* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 6400 to 704 (in bits) (by -5696 bits)
+          type of 'int ()* ()* const l' changed:
+            entity changed from 'int ()* ()* const' to 'int'
+            type size changed from 64 to 32 (in bits)
+          and offset changed from 6464 to 736 (in bits) (by -5728 bits)
+
+  [C] 'function volatile int[7]* n()' at PR30048-test-2-v0.cc:72:1 has some indirect sub-type changes:
+    return type changed:
+      entity changed from 'volatile int[7]*' to 'int'
+      type size changed from 64 to 32 (in bits)
+
+  [C] 'function volatile int* o()' at PR30048-test-2-v0.cc:74:1 has some indirect sub-type changes:
+    return type changed:
+      entity changed from 'volatile int*' to 'int'
+      type size changed from 64 to 32 (in bits)
+
+  [C] 'function int ()* p()' at PR30048-test-2-v0.cc:77:1 has some indirect sub-type changes:
+    return type changed:
+      entity changed from 'int ()*' to 'int'
+      type size changed from 64 to 32 (in bits)
+
diff --git a/tests/data/test-abidiff-exit/PR30048-test-2-v0.cc b/tests/data/test-abidiff-exit/PR30048-test-2-v0.cc
new file mode 100644 (file)
index 0000000..5c1cbe0
--- /dev/null
@@ -0,0 +1,78 @@
+struct amusement {
+  // declare A as array 7 of int
+  int A[7];
+  // declare B as pointer to int
+  int *B;
+  // declare C as pointer to function (void) returning int
+  int (*C)(void );
+  // declare D as array 7 of array 7 of int
+  int D[7][7];
+  // declare E as array 7 of pointer to int
+  int *E[7];
+  // declare F as array 7 of pointer to function (void) returning int
+  int (*F[7])(void );
+  // declare G as pointer to array 7 of int
+  int (*G)[7];
+  // declare H as pointer to pointer to int
+  int **H;
+  // declare I as pointer to function (void) returning int
+  int (*I)(void );
+  // declare J as pointer to function (void) returning pointer to array 7 of int
+  int (*(*J)(void ))[7];
+  // declare K as pointer to function (void) returning pointer to int
+  int *(*K)(void );
+  // declare L as pointer to function (void) returning pointer to function
+  // (void) returning int
+  int (*(*L)(void ))(void );
+
+  // declare a as array 7 of volatile int
+  volatile int a[7];
+  // declare b as const pointer to volatile int
+  volatile int * const b;
+  // declare c as const pointer to function (void) returning int
+  int (* const c)(void );
+  // declare d as array 7 of array 7 of volatile int
+  volatile int d[7][7];
+  // declare e as array 7 of const pointer to volatile int
+  volatile int * const e[7];
+  // declare f as array 7 of const pointer to function (void) returning int
+  int (* const f[7])(void );
+  // declare g as const pointer to array 7 of volatile int
+  volatile int (* const g)[7];
+  // declare h as const pointer to const pointer to volatile int
+  volatile int * const * const h;
+  // declare i as const pointer to function (void) returning int
+  int (* const i)(void );
+  // declare j as const pointer to function (void) returning pointer to array 7
+  //of volatile int
+  volatile int (*(* const j)(void ))[7];
+  // declare k as const pointer to function (void) returning pointer to
+  //volatile int
+  volatile int *(* const k)(void );
+  // declare l as const pointer to function (void) returning pointer to
+  //function (void) returning int
+  int (*(* const l)(void ))(void );
+};
+
+struct amusement * fun(void) { return 0; }
+
+// declare M as function (void) returning int
+int M(void ) { return 0; }
+// declare N as function (void) returning pointer to array 7 of int
+int (*N(void ))[7] { return 0; }
+// declare O as function (void) returning pointer to int
+int *O(void ) { return 0; }
+// declare P as function (void) returning pointer to function (void) returning
+//int
+int (*P(void ))(void ) { return 0; }
+
+// declare m as function (void) returning int
+int m(void ) { return 0; }
+// declare n as function (void) returning pointer to array 7 of volatile int
+volatile int (*n(void ))[7] { return 0; }
+// declare o as function (void) returning pointer to volatile int
+volatile int *o(void ) { return 0; }
+// declare p as function (void) returning pointer to function (void) returning
+//int
+int (*p(void ))(void ) { return 0; }
+
diff --git a/tests/data/test-abidiff-exit/PR30048-test-2-v0.o b/tests/data/test-abidiff-exit/PR30048-test-2-v0.o
new file mode 100644 (file)
index 0000000..a4eafe8
Binary files /dev/null and b/tests/data/test-abidiff-exit/PR30048-test-2-v0.o differ
diff --git a/tests/data/test-abidiff-exit/PR30048-test-2-v1.cc b/tests/data/test-abidiff-exit/PR30048-test-2-v1.cc
new file mode 100644 (file)
index 0000000..2af3296
--- /dev/null
@@ -0,0 +1,39 @@
+struct amusement {
+  int A;
+  int B;
+  int C;
+  int D;
+  int E;
+  int F;
+  int G;
+  int H;
+  int I;
+  int J;
+  int K;
+  int L;
+
+  int a;
+  int b;
+  int c;
+  int d;
+  int e;
+  int f;
+  int g;
+  int h;
+  int i;
+  int j;
+  int k;
+  int l;
+};
+
+struct amusement * fun() { return 0; }
+
+int M() { return 0; }
+int N() { return 0; }
+int O() { return 0; }
+int P() { return 0; }
+
+int m() { return 0; }
+int n() { return 0; }
+int o() { return 0; }
+int p() { return 0; }
diff --git a/tests/data/test-abidiff-exit/PR30048-test-2-v1.o b/tests/data/test-abidiff-exit/PR30048-test-2-v1.o
new file mode 100644 (file)
index 0000000..fdf59d1
Binary files /dev/null and b/tests/data/test-abidiff-exit/PR30048-test-2-v1.o differ
diff --git a/tests/data/test-abidiff-exit/PR30048-test-report-0.txt b/tests/data/test-abidiff-exit/PR30048-test-report-0.txt
new file mode 100644 (file)
index 0000000..23a4c10
--- /dev/null
@@ -0,0 +1,19 @@
+Functions changes summary: 0 Removed, 0 Changed, 0 Added function
+Variables changes summary: 0 Removed, 1 Changed, 0 Added variable
+
+1 Changed variable:
+
+  [C] 'S s' was changed at PR30048-test-v1.c:6:1:
+    size of symbol changed from 56 to 16
+    type of variable changed:
+      type size changed from 448 to 128 (in bits)
+      5 data member deletions:
+        'int (int)* f01', at offset 0 (in bits) at PR30048-test-v0.c:2:1
+        'int (const int*)* f02', at offset 64 (in bits) at PR30048-test-v0.c:3:1
+        'int (int* const)* f03', at offset 128 (in bits) at PR30048-test-v0.c:4:1
+        'int (int* restrict)* f04', at offset 192 (in bits) at PR30048-test-v0.c:5:1
+        'int (const int* restrict)* f05', at offset 256 (in bits) at PR30048-test-v0.c:6:1
+      2 data member changes:
+        'int (int* restrict const)* f06' offset changed from 320 to 0 (in bits) (by -320 bits)
+        'int (int* restrict const)* f07' offset changed from 384 to 64 (in bits) (by -320 bits)
+
diff --git a/tests/data/test-abidiff-exit/PR30048-test-v0.c b/tests/data/test-abidiff-exit/PR30048-test-v0.c
new file mode 100644 (file)
index 0000000..b00f6d7
--- /dev/null
@@ -0,0 +1,12 @@
+struct S {
+  int (*f01)(int);
+  int (*f02)(const int*);
+  int (*f03)(int* const);
+  int (*f04)(int* restrict);
+  int (*f05)(const int* restrict);
+  int (*f06)(int* restrict const);
+  int (*f07)(int* const restrict);
+};
+
+struct S s;
+
diff --git a/tests/data/test-abidiff-exit/PR30048-test-v0.o b/tests/data/test-abidiff-exit/PR30048-test-v0.o
new file mode 100644 (file)
index 0000000..91e136f
Binary files /dev/null and b/tests/data/test-abidiff-exit/PR30048-test-v0.o differ
diff --git a/tests/data/test-abidiff-exit/PR30048-test-v1.c b/tests/data/test-abidiff-exit/PR30048-test-v1.c
new file mode 100644 (file)
index 0000000..21499ac
--- /dev/null
@@ -0,0 +1,6 @@
+struct S {
+  int (*f06)(int* restrict const);
+  int (*f07)(int* const restrict);
+};
+
+struct S s;
diff --git a/tests/data/test-abidiff-exit/PR30048-test-v1.o b/tests/data/test-abidiff-exit/PR30048-test-v1.o
new file mode 100644 (file)
index 0000000..161e456
Binary files /dev/null and b/tests/data/test-abidiff-exit/PR30048-test-v1.o differ
index 9b9bd19a168773208a4c9d6ceb4e8fba54cf9e93..83b3e8368a4e81376fe115459682fb69a63bce7f 100644 (file)
@@ -47,39 +47,39 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
             underlying type 'typedef A' at qualifier-typedef-array-v0.c:1:1 changed:
               entity changed from 'typedef A' to compatible type 'void*[7]'
           type of 'C v_c' changed:
-            entity changed from 'typedef C' to compatible type 'const volatile void*[7]'
+            entity changed from 'typedef C' to compatible type 'void* const volatile[7]'
               array element type 'void* const' changed:
-                'void* const' changed to 'const volatile void*'
-              type name changed from 'void* const[7]' to 'const volatile void*[7]'
+                'void* const' changed to 'void* const volatile'
+              type name changed from 'void* const[7]' to 'void* const volatile[7]'
               type size hasn't changed
           type of 'C r_c' changed:
-            entity changed from 'typedef C' to compatible type 'restrict const void*[7]'
+            entity changed from 'typedef C' to compatible type 'void* restrict const[7]'
               array element type 'void* const' changed:
-                'void* const' changed to 'restrict const void*'
-              type name changed from 'void* const[7]' to 'restrict const void*[7]'
+                'void* const' changed to 'void* restrict const'
+              type name changed from 'void* const[7]' to 'void* restrict const[7]'
               type size hasn't changed
           type of 'D v_d' changed:
-            entity changed from 'typedef D' to compatible type 'const volatile void*[7]'
+            entity changed from 'typedef D' to compatible type 'void* const volatile[7]'
               array element type 'void* const' changed:
-                'void* const' changed to 'const volatile void*'
-              type name changed from 'void* const[7]' to 'const volatile void*[7]'
+                'void* const' changed to 'void* const volatile'
+              type name changed from 'void* const[7]' to 'void* const volatile[7]'
               type size hasn't changed
           type of 'D r_d' changed:
-            entity changed from 'typedef D' to compatible type 'restrict const void*[7]'
+            entity changed from 'typedef D' to compatible type 'void* restrict const[7]'
               array element type 'void* const' changed:
-                'void* const' changed to 'restrict const void*'
-              type name changed from 'void* const[7]' to 'restrict const void*[7]'
+                'void* const' changed to 'void* restrict const'
+              type name changed from 'void* const[7]' to 'void* restrict const[7]'
               type size hasn't changed
           type of 'E r_e' changed:
-            entity changed from 'typedef E' to compatible type 'restrict const volatile void*[7]'
-              array element type 'const volatile void*' changed:
-                'const volatile void*' changed to 'restrict const volatile void*'
-              type name changed from 'const volatile void*[7]' to 'restrict const volatile void*[7]'
+            entity changed from 'typedef E' to compatible type 'void* restrict const volatile[7]'
+              array element type 'void* const volatile' changed:
+                'void* const volatile' changed to 'void* restrict const volatile'
+              type name changed from 'void* const volatile[7]' to 'void* restrict const volatile[7]'
               type size hasn't changed
           type of 'F r_f' changed:
-            entity changed from 'typedef F' to compatible type 'restrict const volatile void*[7]'
-              array element type 'const volatile void*' changed:
-                'const volatile void*' changed to 'restrict const volatile void*'
-              type name changed from 'const volatile void*[7]' to 'restrict const volatile void*[7]'
+            entity changed from 'typedef F' to compatible type 'void* restrict const volatile[7]'
+              array element type 'void* const volatile' changed:
+                'void* const volatile' changed to 'void* restrict const volatile'
+              type name changed from 'void* const volatile[7]' to 'void* restrict const volatile[7]'
               type size hasn't changed
 
index df2f087c08272fe6116cc0821333e3829245e1c7..2424675f9580af97e4c59e54efdf10c48c34d8db 100644 (file)
@@ -471,6 +471,28 @@ InOutSpec in_out_specs[] =
     "data/test-abidiff-exit/test-rhbz2114909-report-1.txt",
     "output/test-abidiff-exit/test-rhbz2114909-report-1.txt"
   },
+  {
+    "data/test-abidiff-exit/PR30048-test-v0.o",
+    "data/test-abidiff-exit/PR30048-test-v1.o",
+    "",
+    "",
+    "",
+    "--no-default-suppression",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/PR30048-test-report-0.txt",
+    "output/test-abidiff-exit/PR30048-test-report-0.txt"
+  },
+  {
+    "data/test-abidiff-exit/PR30048-test-2-v0.o",
+    "data/test-abidiff-exit/PR30048-test-2-v1.o",
+    "",
+    "",
+    "",
+    "--no-default-suppression",
+    abigail::tools_utils::ABIDIFF_ABI_CHANGE,
+    "data/test-abidiff-exit/PR30048-test-2-report-1.txt",
+    "output/test-abidiff-exit/PR30048-test-2-report-1.txt"
+  },
 #ifdef WITH_BTF
   {
     "data/test-abidiff-exit/btf/test0-v0.o",