On 11/20/20 2:57 PM, Jakub Jelinek wrote:
On Fri, Nov 20, 2020 at 02:54:34PM -0700, Martin Sebor wrote:
At the point the attribute is created there is no SAVE_EXPR. So for
something like:
int f (void);
void g (int a[f () + 1]) { }
the bound is a PLUS_EXPR (CALL_EXPR (f), 1).
I don't do anything with the expression except put them on the chain
of arguments to the two attributes and print them in warnings.
So that likely means you are doing it too early.
The bounds are added to attribute "arg spec" for each param in
push_parm_decl. I think that's both as early and (except maybe
in function definitions) as late as can be. After that point,
the association between a VLA parameter and its most significant
bound is lost.
For example, in:
void f (int n, int A[n], int B[foo () + 1]);
A and B become pointers in push_parm_decl() (in grokdeclarator()
called from it) and there's no way that I know to retrieve
the bounds at a later point. AFAICT, they're gone unless
the function is being defined. Is there another/better point
to extract this association that escapes me?
The VLA bounds are evaluated in function definitions so there
must be a point where that's done. I don't know where that
happens but unless at that point the most significant bound
is still associated with the param (AFAIK, it never really
is at the tree level) it wouldn't help me.
Martin