Commit e4493c04 by Richard Kenner

(expand_builtin, case BUILT_IN_NEXT_ARG): Test whether an argunment

has been passed to __builtin_next_arg; warn if not.

From-SVN: r6994
parent 18e2b1c0
...@@ -6961,8 +6961,6 @@ expand_builtin (exp, target, subtarget, mode, ignore) ...@@ -6961,8 +6961,6 @@ expand_builtin (exp, target, subtarget, mode, ignore)
case BUILT_IN_NEXT_ARG: case BUILT_IN_NEXT_ARG:
{ {
tree fntype = TREE_TYPE (current_function_decl); tree fntype = TREE_TYPE (current_function_decl);
tree last_parm = tree_last (DECL_ARGUMENTS (current_function_decl));
tree arg;
if (TYPE_ARG_TYPES (fntype) == 0 if (TYPE_ARG_TYPES (fntype) == 0
|| (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype))) || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
...@@ -6973,9 +6971,13 @@ expand_builtin (exp, target, subtarget, mode, ignore) ...@@ -6973,9 +6971,13 @@ expand_builtin (exp, target, subtarget, mode, ignore)
return const0_rtx; return const0_rtx;
} }
arg = TREE_VALUE (arglist); if (arglist)
/* Strip off all nops for the sake of the comparison. This is not {
quite the same as STRIP_NOPS. It does more. */ tree last_parm = tree_last (DECL_ARGUMENTS (current_function_decl));
tree arg = TREE_VALUE (arglist);
/* Strip off all nops for the sake of the comparison. This
is not quite the same as STRIP_NOPS. It does more. */
while (TREE_CODE (arg) == NOP_EXPR while (TREE_CODE (arg) == NOP_EXPR
|| TREE_CODE (arg) == CONVERT_EXPR || TREE_CODE (arg) == CONVERT_EXPR
|| TREE_CODE (arg) == NON_LVALUE_EXPR) || TREE_CODE (arg) == NON_LVALUE_EXPR)
...@@ -6983,6 +6985,11 @@ expand_builtin (exp, target, subtarget, mode, ignore) ...@@ -6983,6 +6985,11 @@ expand_builtin (exp, target, subtarget, mode, ignore)
if (arg != last_parm) if (arg != last_parm)
warning ("second parameter of `va_start' not last named argument"); warning ("second parameter of `va_start' not last named argument");
} }
else
/* Evidently an out of date version of <stdarg.h>; can't validate
va_start's second argument, but can still work as intended. */
warning ("`__builtin_next_arg' called without an argument");
}
return expand_binop (Pmode, add_optab, return expand_binop (Pmode, add_optab,
current_function_internal_arg_pointer, current_function_internal_arg_pointer,
......
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