aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/mips/va-arg-1.c
blob: 87c95f525fb83086debab003c764962d48a9dfe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* See PR 52154 for the xfail.  */
/* { dg-do run { xfail { mips_eabi && { hard_float && ilp32 } } } } */

#include <stdarg.h>

extern void abort (void);

struct __attribute__((aligned(16))) empty {};

static void __attribute__((noinline))
check_args (int count, ...)
{
  va_list va;
  int i;

  va_start (va, count);
  for (i = 0; i < count; i++)
    if (va_arg (va, int) != 1000 + i)
      abort ();

  va_arg (va, struct empty);
  if (va_arg (va, int) != 2000 + count)
    abort ();

  va_end (va);
}

int
main (void)
{
  struct empty e;

  check_args (1, 1000, e, 2001);
  check_args (2, 1000, 1001, e, 2002);
  check_args (3, 1000, 1001, 1002, e, 2003);
  check_args (4, 1000, 1001, 1002, 1003, e, 2004);
  check_args (5, 1000, 1001, 1002, 1003, 1004, e, 2005);
  check_args (6, 1000, 1001, 1002, 1003, 1004, 1005, e, 2006);
  check_args (7, 1000, 1001, 1002, 1003, 1004, 1005, 1006, e, 2007);
  check_args (8, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, e, 2008);
  check_args (9, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
	      1008, e, 2009);
  check_args (10, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
	      1008, 1009, e, 2010);
  check_args (11, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007,
	      1008, 1009, 1010, e, 2011);
  return 0;
}