This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
> in tree.def, in DEFTREECODE for call_expr, it says operand 2 is the > static chain argument, or NULL. Can someone tell me or reference me to > what static chain argument is?
It's for nested functions, eg
int parent (int n) { int child (int m) { return m * n; }
return child (2); }
Notice how child using a variable of parent, namely the parameter n. This gets lowered to something like:
struct frame { int n; };
int child (struct frame *static_chain, int m) { return m * static_chain->n; }
int parent (int n) { struct frame FRAME; FRAME.n = n; return child (&FRAME, 2); }
Ah, nice, didn't know that was possible in C. Is that new in C99 or it's a GCC extension?
Ciao,
Duncan.
-- Paulo Jorge Matos - pocm at soton.ac.uk http://www.personal.soton.ac.uk/pocm PhD Student @ ECS University of Southampton, UK
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |