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


#include "mpx-check.h"

struct s1
{
  int *p;
  int i1;
  int i2;
} s1;

int rd (struct s1 s)
{
  int res = s.p[s.i1 + s.i2];
  printf ("%d\n", res);
  return res;
}

int buf[100];

int mpx_test (int argc, const char **argv)
{
  struct s1 s;
  s.p = buf;
  s.i1 = 50;
  s.i2 = -50;

  rd (s);

  s.i1 = 50;
  s.i2 = 49;

  rd (s);

  return 0;
}