Am Montag, dem 05.08.2024 um 13:59 +0200 schrieb Alejandro Colomar: > On Mon, Aug 05, 2024 at 01:58:18PM GMT, Alejandro Colomar wrote: > > On Mon, Aug 05, 2024 at 01:57:35PM GMT, Alejandro Colomar wrote: > > > On Mon, Aug 05, 2024 at 01:55:50PM GMT, Alejandro Colomar wrote: > > > > Hi Martin, > > > > > > > > On Sun, Aug 04, 2024 at 11:39:26AM GMT, Martin Uecker wrote: > > > > > > BTW, I still don't understand what `if (! TYPE_DOMAIN (type))` > > > > > > means, > > > > > > within array_type_nelts_minus_one(). What code triggers that > > > > > > condition? > > > > > > Am I missing error handling for that? Thanks! > > > > > > > > > > For incomplete arrays, basically we have the following different > > > > > variants for arrays: > > > > > > > > > > T[ ] incomplete: !TYPE_DOMAIN > > > > > T[1] constant size: TYPE_MAX_VALUE == INTEGER_CST > > > > > T[n] variable size: TYPE_MAX_VALUE != INTEGER_CST > > > > > T[0] flexible array member: !TYPE_MAX_VALUE && !C_TYPE_VARIABLE_SIZE > > > > > (ISO version T[0] has TYPE_SIZE == NULL_TREE) > > > > > T[*] unspecified variable size: !TYPE_MAX_VALUE && > > > > > C_TYPE_VARIABLE_SIZE > > > > > > > > Could you describe the following types? I've repeated the ones you > > > > already described, deduplicated some that have a different meaning in > > > > different contexts, and added some multi-dimensional arrays. > > > > > > > > T[ ] (incomplete type; function parameter) > > > > T[ ] (flexible array member) > > > > T[0] (zero-size array) > > > > T[0] (GNU flexible array member) > > > > T[1] (old flexible array member) > > > > T[7] (constant size) > > > > T[7][n] (constant size with inner variable size) > > > > T[7][*] (constant size with inner unspecified size) > > > > > > And please also describe T[7][4], although I expect that to be just the > > > same as T[7]. > > > > And it would also be interesting to describe T[7][ ]. > > And maybe also: > > T[n][m] > T[n][*] > T[n][ ] > T[n][7]
I do not understand your question. What do you mean by "describe the type"? But I think you might make it unnecessarily complicated. It should be sufficient to look at the outermost size. You can completely ignore thatever happens There should be three cases if I am not mistaken: - incomplete (includes ISO FAM) -> error - constant (includes GNU FAM) -> return fixed size - variable (includes unspecified) -> evaluate the argument and return the size, while making sure it is visibly non-constant. To check that the array has a variable length, you can use the same logic as in comptypes_internal (cf. d1_variable). It is possible that you can not properly distinguish between int a[0][n]; int a[*][n]; those two cases. The logic will treat the first as the second. I think this is ok for now. All this array stuff should be implified and refactored anyway, but this is for another time. I am also not sure you even need to use array_type_nelts in C because there is never a non-zero minimum size. Martin > > > > > > > > > > T[n] (variable size) > > > > T[*] (unspecified size) > > > > > > > > That would help with the [*] issues I'm investigating. I think > > > > array_type_nelts_minus_one(T[7][*]) is not giving a constant expression, > > > > and I'd like to fix that. > > > > > > > > Have a lovely day! > > > > Alex > > > > > > > > -- > > > > <https://www.alejandro-colomar.es/> > > > > > > > > > > > > -- > > > <https://www.alejandro-colomar.es/> > > > > > > > > -- > > <https://www.alejandro-colomar.es/> > > >