From: Michael Beck Date: Tue, 23 Sep 2008 17:13:40 +0000 (+0000) Subject: - add missing initialization of have_const_functions X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=e53f30472457acff3fcac2c70385307c70e41873;p=cparser - add missing initialization of have_const_functions [r22214] --- diff --git a/ast2firm.c b/ast2firm.c index 6c47533..1c06786 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -64,6 +64,8 @@ static int inner_function_idx; static ir_node *ijmp_list; static bool constant_folding; +extern bool have_const_functions; + static const declaration_t *current_function_decl; static ir_node *current_function_name; static ir_node *current_funcsig; @@ -1049,6 +1051,7 @@ static void handle_gnu_attributes_ent(ir_entity *ent, declaration_t *decl) } if (decl->modifiers & DM_CONST) { set_entity_additional_property(ent, mtp_property_const); + have_const_functions = true; } if (decl->modifiers & DM_USED) { /* TRUE if the declaration includes the GNU diff --git a/driver/firm_opt.c b/driver/firm_opt.c index ed28ec9..ee3f580 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -303,7 +303,7 @@ static int firm_const_exists; static void do_optimize_funccalls(void) { - optimize_funccalls(true, NULL); + optimize_funccalls(firm_const_exists, NULL); } static void do_gcse(ir_graph *irg) diff --git a/main.c b/main.c index d75333d..1dd4976 100644 --- a/main.c +++ b/main.c @@ -114,6 +114,9 @@ bool strict_mode = false; /** use builtins for some libc functions */ bool use_builtins = false; +/** we have extern function with const attribute. */ +bool have_const_functions = false; + /* to switch on printing of implicit casts */ extern bool print_implicit_casts; @@ -1131,7 +1134,7 @@ int main(int argc, char **argv) } gen_firm_finish(asm_out, filename, /*c_mode=*/1, - /*firm_const_exists=*/0); + have_const_functions); if (asm_out != out) { fclose(asm_out); }