Commit 2c1c10ec by Richard Kenner

(output_decl...

(output_decl, case FUNCTION_DECL): Corrected and simplified code that
determined when to generate varargs or ANSI stdargs variable length
parameter list DWARF information.

From-SVN: r7816
parent 62acb978
......@@ -4435,25 +4435,9 @@ output_decl (decl, containing_scope)
output_formal_types (TREE_TYPE (decl));
else
{
register tree arg_decls = DECL_ARGUMENTS (decl);
{
register tree last_arg;
last_arg = (arg_decls && TREE_CODE (arg_decls) != ERROR_MARK)
? tree_last (arg_decls)
: NULL;
/* Generate DIEs to represent all known formal parameters, but
don't do it if this looks like a varargs function. A given
function is considered to be a varargs function if (and only
if) its last named argument is named `__builtin_va_alist'. */
/* Generate DIEs to represent all known formal parameters */
if (! last_arg
|| ! DECL_NAME (last_arg)
|| strcmp (IDENTIFIER_POINTER (DECL_NAME (last_arg)),
"__builtin_va_alist"))
{
register tree arg_decls = DECL_ARGUMENTS (decl);
register tree parm;
/* WARNING! Kludge zone ahead! Here we have a special
......@@ -4485,70 +4469,59 @@ output_decl (decl, containing_scope)
needed to represent the types of these formal parameters.
*/
/*
When generating DIEs, generate the unspecified_parameters
DIE instead if we come across the arg "__builtin_va_alist"
*/
for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
if (TREE_CODE (parm) == PARM_DECL)
{
if (DECL_NAME(parm) &&
!strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
"__builtin_va_alist") )
output_die (output_unspecified_parameters_die, decl);
else
output_decl (parm, fake_containing_scope);
}
/* Now that we have finished generating all of the DIEs to
/*
Now that we have finished generating all of the DIEs to
represent the formal parameters themselves, force out
any DIEs needed to represent their types. We do this
simply by un-pending all previously pended types which
can legitimately go into the chain of children DIEs for
the current FUNCTION_DECL. */
the current FUNCTION_DECL.
*/
output_pending_types_for_scope (decl);
}
}
/* Now try to decide if we should put an ellipsis at the end. */
/*
Decide whether we need a unspecified_parameters DIE at the end.
There are 2 more cases to do this for:
1) the ansi ... declaration - this is detectable when the end
of the arg list is not a void_type_node
2) an unprototyped function declaration (not a definition). This
just means that we have no info about the parameters at all.
*/
{
register int has_ellipsis = TRUE; /* default assumption */
register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
if (fn_arg_types)
{
/* This function declaration/definition was prototyped. */
/* If the list of formal argument types ends with a
void_type_node, then the formals list did *not* end
with an ellipsis. */
if (TREE_VALUE (tree_last (fn_arg_types)) == void_type_node)
has_ellipsis = FALSE;
/* this is the prototyped case, check for ... */
if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
output_die (output_unspecified_parameters_die, decl);
}
else
{
/* This function declaration/definition was not prototyped. */
/* Note that all non-prototyped function *declarations* are
assumed to represent varargs functions (until proven
otherwise). */
if (DECL_INITIAL (decl)) /* if this is a func definition */
{
if (!arg_decls)
has_ellipsis = FALSE; /* no args == (void) */
else
{
/* For a non-prototyped function definition which
declares one or more formal parameters, if the name
of the first formal parameter is *not*
__builtin_va_alist then we must assume that this
is *not* a varargs function. */
if (DECL_NAME (arg_decls)
&& strcmp (IDENTIFIER_POINTER (DECL_NAME (arg_decls)),
"__builtin_va_alist"))
has_ellipsis = FALSE;
}
}
}
if (has_ellipsis)
/* this is unprotoyped, check for undefined (just declaration) */
if (!DECL_INITIAL (decl))
output_die (output_unspecified_parameters_die, decl);
}
}
}
/* Output Dwarf info for all of the stuff within the body of the
function (if it has one - it may be just a declaration). */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment