This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: implicit gnat_malloc seen as vararg function


Hi,

I have more info concerning my gnat_malloc problem.

I watched the code in gcc/ada/gcc-interface/trans.c and found the location where malloc_decl tree is built.
In gigi ()function (trans.c:411), the ftype for malloc_decl is done this way :

  ftype = build_function_type_list (ptr_void_type_node, sizetype, NULL_TREE);

I looked at the code of build_function_type_list_1 in tree.c and found that stdargs function are built with their chained list of argument ending with a void_list_node :

    {
      last = args;
      args = nreverse (args);
      TREE_CHAIN (last) = void_list_node;
    }

But I also noticed that void_list_node was a null pointer!! instead of being a node with TREE_VALUE = void_type_node and no TREE_CHAIN  (as described in tree.h)
So I wondered, where should void_list_node be initialized in GNAT frontend and noticed that the initialization of void_list_node was done AFTER its use to declare ftype for malloc_decl.

ftype  for malloc_decl is initialized in gigi() function at trans.c:411  whereas void_list_node in only initialized in gigi() function at trans.c:665 by a call to gnat_install_builtins() ---> install_builtin_elementary_types()  --> void_list_node = build_void_list_node ();


It seems like a bug. Is it a known one ? someone has the proper fix ? I put the call to gnat_install_builtins() higher inside gigi() and it solve my current problem but I'm not sure exactly when it has to be called and if there are bad side effects.

    Regards,

Selim Belbachir



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]