summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c
blob: 6bf4721f75adfcbfc926832e83cf1d765d4d40b8 (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
/* { dg-do run } */
/* { dg-options "-fcheck-pointer-bounds -mmpx" } */

/* { dg-additional-options "-Wno-attributes" } */

#include "mpx-check.h"
#include <stdarg.h>

int
foo2 (int i1, int *p1, ...)
{
  va_list argp;
  int *p;
  int i;
  int res;

  va_start(argp, p1);
  p = va_arg(argp, int *);
  i = va_arg(argp, int);

  res = p[i + i1];
  printf("%d\n", res);

  return res;
}

static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
  return foo2 (10, p1, __builtin_va_arg_pack ());
}

int prebuf[100];
int buf[100];
int buf1[100];
int postbuf[100];

int mpx_test (int argc, const char **argv)
{
  foo1 (buf, buf1, 89);
  foo1 (buf, buf1, -9);
  return 0;
}