I’m trying to get the Fortran front-end to add function-specific optimization flags to certain functions (those that request IEEE compliance through use of the specific Fortran module). It seems simple enough, adding the attribute to the fndecl, but though I’ve tried to do so at two different places (when we first build the function decl, and when we later call it), both fail with:
Warning: ‘optimize’ attribute directive ignored [-Wattributes] I’m getting the feeling that maybe it’s because I gave the attribute a string value, and it’s expecting a tree already… but the functions to do so are not generic, they’re in c-family, which probably means I can’t use them. Any idea how I could get to the result I want? (setting options from the Fortran front-end) Thanks, FX Index: trans-decl.c =================================================================== --- trans-decl.c (revision 215668) +++ trans-decl.c (working copy) @@ -1961,6 +1961,13 @@ TREE_USED (fndecl) = 1; attributes = add_attributes_to_decl (attr, NULL_TREE); + +#define OPT "fno-unsafe-math-optimizations" + tree opt = build_tree_list (NULL_TREE, build_string (strlen (OPT), OPT)); + attributes = tree_cons (get_identifier ("optimize"), opt, attributes); +#undef OPT + decl_attributes (&fndecl, attributes, 0); /* Figure out the return type of the declared function, and build a @@ -5760,8 +5767,19 @@ the floating point state. */ ieee = is_ieee_module_used (ns); if (ieee) - fpstate = save_fp_state (&init); + { + tree attributes; + fpstate = save_fp_state (&init); + +#define OPT "fno-unsafe-math-optimizations" + tree opt = build_tree_list (NULL_TREE, build_string (strlen (OPT), OPT)); + attributes = tree_cons (get_identifier ("optimize"), opt, NULL_TREE); + decl_attributes (&fndecl, attributes, 0); +#undef OPT + } + /* Now generate the code for the body of this function. */ gfc_init_block (&body);