libctf: fix cv-qualified unnamed struct/union field lookup

GCC permits not only unnamed structs and unions, but cv-qualified ones.
Our earlier fix in 6c3a38777b supported
unnamed structs and unions, but only unqualified ones.

Resolving away cvr-quals of nameless fields (and, irrelevantly, typedefs)
is easy and fixes this problem.

Tests adjusted accordingly.

libctf/
	PR libctf/32746
	* ctf-types.c (ctf_member_next): Resolve away cv-quals.
	(ctf_member_info): Likewise.
	* testsuite/libctf-lookup/struct-iteration-ctf.c: Add a cv-qualified
	type or two: make sure to keep a non-qualified one.
	* testsuite/libctf-lookup/struct-iteration.c: Verify consistency
	of ctf_member_next and ctf_member_info.
	* testsuite/libctf-lookup/struct-iteration.lk: Adjust.

Tested-by: Stephen Brennan <stephen.s.brennan@oracle.com>
This commit is contained in:
Nick Alcock
2025-02-24 18:11:25 +00:00
parent 83e8a5d39b
commit fa4fe27537
4 changed files with 55 additions and 13 deletions

View File

@@ -4,8 +4,8 @@ iter test: foo, offset [0-9a-f]*, has type [0-9a-f]*/int
iter test: bar, offset [0-9a-f]*, has type [0-9a-f]*/size_t
iter test: baz, offset [0-9a-f]*, has type [0-9a-f]*/const char \*
iter test: self, offset [0-9a-f]*, has type [0-9a-f]*/struct foo_t \*
iter test: named, offset [0-9a-f]*, has type [0-9a-f]*/union
iter test: , offset [0-9a-f]*, has type [0-9a-f]*/struct
iter test: named, offset [0-9a-f]*, has type [0-9a-f]*/volatile const union
iter test: , offset [0-9a-f]*, has type [0-9a-f]*/volatile const struct
iter test: , offset [0-9a-f]*, has type [0-9a-f]*/struct
iter test: , offset [0-9a-f]*, has type [0-9a-f]*/union
iter test: after_the_end, offset [0-9a-f]*, has type [0-9a-f]*/int
@@ -13,12 +13,14 @@ next test: foo, offset [0-9a-f]*, has type [0-9a-f]*/int
next test: bar, offset [0-9a-f]*, has type [0-9a-f]*/size_t
next test: baz, offset [0-9a-f]*, has type [0-9a-f]*/const char \*
next test: self, offset [0-9a-f]*, has type [0-9a-f]*/struct foo_t \*
next test: named, offset [0-9a-f]*, has type [0-9a-f]*/union
next test: , offset [0-9a-f]*, has type [0-9a-f]*/struct
next test: named, offset [0-9a-f]*, has type [0-9a-f]*/volatile const union
next test: , offset [0-9a-f]*, has type [0-9a-f]*/volatile const struct
next test: unnamed_sub_member, offset [0-9a-f]*, has type [0-9a-f]*/long int
next test: , offset [0-9a-f]*, has type [0-9a-f]*/union
next test: one_more_level, offset [0-9a-f]*, has type [0-9a-f]*/double
next test: yes_really_one_more, offset [0-9a-f]*, has type [0-9a-f]*/long int
next test: , offset [0-9a-f]*, has type [0-9a-f]*/struct
next test: and_finally, offset [0-9a-f]*, has type [0-9a-f]*/int
next test: , offset [0-9a-f]*, has type [0-9a-f]*/struct
next test: , offset [0-9a-f]*, has type [0-9a-f]*/union
next test: after_the_end, offset [0-9a-f]*, has type [0-9a-f]*/int