function.c (assign_parms): Set last_named only for last named argument.
* function.c (assign_parms): Set last_named only for last named argument. * g++.dg/other/stdarg1.C: New test. From-SVN: r47601
This commit is contained in:
parent
5402e639e2
commit
108b7d3d31
|
@ -1,3 +1,8 @@
|
|||
2001-12-04 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* function.c (assign_parms): Set last_named only for last named
|
||||
argument.
|
||||
|
||||
2001-12-04 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* doc/install.texi: Use the GFDL. Include years from old install
|
||||
|
|
|
@ -4307,16 +4307,25 @@ assign_parms (fndecl)
|
|||
tree passed_type = DECL_ARG_TYPE (parm);
|
||||
tree nominal_type = TREE_TYPE (parm);
|
||||
int pretend_named;
|
||||
int last_named = 0, named_arg;
|
||||
|
||||
/* Set LAST_NAMED if this is last named arg before some
|
||||
/* Set LAST_NAMED if this is last named arg before last
|
||||
anonymous args. */
|
||||
int last_named = ((TREE_CHAIN (parm) == 0
|
||||
|| DECL_NAME (TREE_CHAIN (parm)) == 0)
|
||||
&& (stdarg || current_function_varargs));
|
||||
if (stdarg || current_function_varargs)
|
||||
{
|
||||
tree tem;
|
||||
|
||||
for (tem = TREE_CHAIN (parm); tem; tem = TREE_CHAIN (tem))
|
||||
if (DECL_NAME (tem))
|
||||
break;
|
||||
|
||||
if (tem == 0)
|
||||
last_named = 1;
|
||||
}
|
||||
/* Set NAMED_ARG if this arg should be treated as a named arg. For
|
||||
most machines, if this is a varargs/stdarg function, then we treat
|
||||
the last named arg as if it were anonymous too. */
|
||||
int named_arg = STRICT_ARGUMENT_NAMING ? 1 : ! last_named;
|
||||
named_arg = STRICT_ARGUMENT_NAMING ? 1 : ! last_named;
|
||||
|
||||
if (TREE_TYPE (parm) == error_mark_node
|
||||
/* This can happen after weird syntax errors
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2001-12-04 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* g++.dg/other/stdarg1.C: New test.
|
||||
|
||||
2001-12-03 Janis Johnson <janis187@us.ibm.com>
|
||||
|
||||
* gcc.c-torture/execute/builtin-prefetch-1.c: New test.
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
// Test stdarg function with anonymous argument
|
||||
// { dg-do run }
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
extern "C" void abort (void);
|
||||
|
||||
void baz (va_list list)
|
||||
{
|
||||
if (va_arg (list, long) != 3)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void foo (long p1, long, long p2, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start (list, p2);
|
||||
baz (list);
|
||||
va_end (list);
|
||||
}
|
||||
|
||||
int main ()
|
||||
{
|
||||
foo (0, 1, 2, 3);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue