TREE_ADDRESSABLE comment says "In a FUNCTION_DECL, nonzero means its address is needed". However, as I point out in http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html, this flag gets set when making normal calls. It wasn't always like this. gcc-4.0 was careful to not set TREE_ADDRESSABLE on FUNCTION_DECLs in build_function_call, a feature lost in revision 100984. I'd like to have that feature back for the above patch. Bootstrapped and regression tested powerpc-linux. OK for 4.6?
* c-typeck.c (build_function_call_vec): Avoid setting TREE_ADDRESSABLE on normal function calls. Index: gcc/c-typeck.c =================================================================== --- gcc/c-typeck.c (revision 170607) +++ gcc/c-typeck.c (working copy) @@ -2715,7 +2715,20 @@ build_function_call_vec (location_t loc, fundecl = function; } if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE) - function = function_to_pointer_conversion (loc, function); + { + if (fundecl) + { + /* Don't set TREE_ADDRESSABLE for the implicit function + pointer conversion in a function call. This allows + TREE_ADDRESSABLE to be used to detect explicit function + address operations. */ + bool addressable = TREE_ADDRESSABLE (fundecl); + function = function_to_pointer_conversion (loc, function); + TREE_ADDRESSABLE (fundecl) = addressable; + } + else + function = function_to_pointer_conversion (loc, function); + } /* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF expressions, like those used for ObjC messenger dispatches. */ -- Alan Modra Australia Development Lab, IBM