Mismatched types in ADDR_EXPR from c-typeck.c:build_function_call
Joseph S. Myers
joseph@codesourcery.com
Wed May 18 13:11:00 GMT 2005
On Wed, 18 May 2005, Richard Guenther wrote:
> The following snippet
>
> /* Differs from default_conversion by not setting TREE_ADDRESSABLE
> (because calling an inline function does not mean the function
> needs to be separately compiled). */
> fntype = build_type_variant (TREE_TYPE (function),
> TREE_READONLY (function),
> TREE_THIS_VOLATILE (function));
> fundecl = function;
> function = build1 (ADDR_EXPR, build_pointer_type (fntype),
> function);
If you want to avoid this then you need to arrange for const and noreturn
attributes on functions always to be represented by qualifiers on the type
and not on the decl. This is part of bug 3481.
(a) Change handle_noreturn_attribute and handle_const_attribute to put the
qualifiers on the type in addition to the decl. This might be all you
need to avoid the above code creating undesirable type variants, but I
wouldn't be at all confident of that.
(b) You'll probably need to change the code that autodetects const
functions to do the same, and if there's any code autodetecting noreturn
functions then likewise. Also any code generating built-in functions
without going through the attribute handling (e.g. local_define_builtin in
tree.c).
(c) Ideally find all places looking at qualifiers on the decl to ascertain
these properties of functions and change them to look at properties of the
type. This should yield better results for calls through function
pointers.
(d) At that point it should be possible to change const and noreturn to
straight function type attributes. Code like the above, expecting to find
qualifiers on the decl, would however need to be changed.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
More information about the Gcc
mailing list