> On 5/31/07, Seema S. Ravandale <[EMAIL PROTECTED]> wrote: >> Hi... >> This is Seema here. I am working on GCC in IITB as research fellow. >> >> Actually i am trying to find out scope information of a variable. > >> But i >> didnt find any information within "decl" data structure of a variable. > > It's there, it's in DECL_CONTEXT. > > DECL_CONTEXT (var) == NULL if it is global scope > otherwise > DECL_CONTEXT (var) == a FUNCTION_DECL which is the variable's scope. > >> somewhere i read that "level # attribute" gives the inforamtion about >> scope. but i am looking at "decl" details just after lowering of GIMPLE >> and that field is NULL. >> >> Is there any other way to find out scope of variable?? Is there any >> information in "decl" data structure so that i can access symbol table >> entry?? >
Ok.. i got it context thing. But what about a variables declared in same functions but in different scope. In gimple, for every new scope there is new BIND_EXPR, having its own var_list and stmt_list. But after lowering there is no such bind_expr. I will give u one example of dump of lowered gimple: int main() { int b; b =0; { int b; b = 1; printf("%d",b); } printf("%d",b); return 0; } Lowered Gimple: main () { int b; int b; int D.1120; b = 0; b = 1; printf (&"%d"[0], b); printf (&"%d"[0], b); D.1120 = 0; goto <D1124>; <D1124>:; return D.1120; } I have seen the details of lowered gimple data structure. Now how to find out scope of variable "b"?? And one more thing: Sometimes GCC creates local version of global variable, I mean for every use of global var say "a", local variable "a.0", "a.1".. are initialised to "a" just before use. and in case of local variables, when local var are used as array index, same temporary variables are created. e.g int a=0; int main() { int c=0; int array[10]; array[c]=a; } In Gimple/Generic array[c] = a; this sentance is going to be replaced as: c.0 = c; a.1 = a; array[c.0]=a.1; so how to decide, tempory of kind c.0 correspond to var "c", not looking at name?? is there some inforamtion in "decl" data structure to access symbol table?? -Seema