On 6/28/22 13:01, Qing Zhao wrote:
On Jun 28, 2022, at 2:49 PM, Jakub Jelinek <ja...@redhat.com> wrote:
On Tue, Jun 28, 2022 at 06:29:01PM +0000, Qing Zhao wrote:
On Jun 28, 2022, at 2:22 PM, Jakub Jelinek <ja...@redhat.com> wrote:
On Tue, Jun 28, 2022 at 06:15:58PM +0000, Qing Zhao wrote:
Because the flag just tells whether some array shouldn't be treated as (poor
man's)
flexible array member. We still need to find out if some FIELD_DECL is to
be treated like a flexible array member, which is a minority of
COMPONENT_REFs.
struct S { int a; char b[0]; int c; } s;
struct T { int d; char e[]; };
struct U { int f; struct T g; int h; } u;
Neither s.b nor u.g.e is to be treated like flexible array member,
no matter what -fstrict-flex-array= option is used.
Then, to resolve this issue, we might need a opposite flag DECL_IS_FLEXARRAY
in FIELD_DECL?
The default is FALSE for all FIELD_DECL.
Doesn't matter whether it is positive or negative, you still need to analyze
it. See the above example. If you have struct T t; and test t.e, then it
is flexarray. But u.g.e is not, even when the COMPONENT_REF refers to the
same FIELD_DECL. In the t.e case e is the very last field, in the latter
case u.g.e is the last field in struct T, but struct U has the h field after
So, do you mean that the current FE analysis will not be able to decide whether
a specific array field is at the end of the enclosing structure?
Only the middle end can decide this ?
Well, anything that analyzes it, can be in the FE or middle-end, but there
is no place to store it for later.
Then I am a little confused:
If the FE can decide wether an array field is at the end of the enclosing
structure, then combined with whether it’s a [0], [1] or [], and which level
of -fstrict-flex-array,
The FE should be able to decide whether this array field is a flexible array
member or not, then set the flag DECL_IS_FLEXARRAY (or DECL_NOT_FLEXARRAY).
The new flag is the place to store such info, right?
Do I miss anything here?
I think the problem is that there is just one FIELD_DECL for member
M of a given type T but there can be more than one instance of that
member, one in each struct that has a subobject of T as its own
member. Whether M is or isn't a (valid) flexible array member
varies between the two instances.
Martin