http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51589
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic CC| |burnus at gcc dot gnu.org --- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-12-17 09:15:44 UTC --- As Harald already mentioned, GCC 4.5 (or later) support -fcheck=do to find modifications to the DO variables at run time. * * * Currently, the do-variable check is done only at parse time via "gfc_check_do_variable"; it uses gfc_state_stack to save the information about the do variables [gfc_state_stack(->previous...)->do_variable], but this information is lost at resolution time - on the other hand, the INTENT_OUT is often not known at parse time. One possibility is to generate a stack of do variables and save a link to it, e.g., in gfc_code. Something like: struct gfc_do_var_list { struct gfc_do_var_list *previous; gfc_symbol *do_var; } struct gfc_do_var_list *gfc_current_do_var = NULL; The gfc_current_do_var is saved in gfc_code; every time a new DO loop is started, a new item is generated and assigned to gfc_current_do_var - after the DO loop, one sets gfc_current_do_var = gfc_current_do_var->previous. That will generate a tree-like structure, which looks like a stack. (One probably needs another linked list to store the gfc_current_do_var - as chain not as tree - for freeing the list.)