This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Mismatched types in ADDR_EXPR from c-typeck.c:build_function_call
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 18 May 2005 12:42:28 +0000 (UTC)
- Subject: Re: Mismatched types in ADDR_EXPR from c-typeck.c:build_function_call
- References: <Pine.LNX.4.44.0505181322490.5176-100000@alwazn.tat.physik.uni-tuebingen.de>
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)