On Mar 14, 2012, at 5:08 PM, Richard Guenther wrote:
> On Wed, 14 Mar 2012, Tristan Gingold wrote:
>> the code to call expand_main_function currently only checks DECL_NAME. This
>> to a hack in ada/gcc-interface/utils.c to handle the gnatbind generated file
>> that could
>> package ada_main is
>> function my_main
>> (argc : Integer;
>> argv : System.Address;
>> envp : System.Address)
>> return Integer;
>> pragma Export (C, my_main, "main");
>> end ada_main;
>> But expand_main_function is also called for function whose name is main but
>> assembly name isn't. Eg:
>> package pkg is
>> procedure main;
>> end pkg;
>> So I think we should consider the assembler name is set, otherwise the decl
>> Manually tested on ia64-hp-openvms (where this issue was discovered).
>> No C regressions for x86_64-darwin.
>> Ok for trunk ?
> There are more checks for MAIN_NAME_P, so this certainly isn't enough.
> And if it is a good idea then the whole check, whether a FUNCTION_DECL
> is considered 'main' should be put into a function in tree.[ch] and
> used everywhere. Note that what is 'main' is controlled by
> main_identifier_node, controlled by frontends. So - why is that not
> enough to control for Ada?
Indeed, I think we could handle this issue in gigi for Ada. (I also think
we don't want to handle crazy C code such as 'int my_main () asm ("main")'.
But, unless I missed something, doing this in gigi won't work with LTO.
Will write a predicate in tree.[ch].
Thank you for your comments,