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


#include "mpx-check.h"

struct S {
  int a[10];
  int b;
} S;

struct S1 {
  int a;
  struct S b[10];
  int c;
} S1;

struct S2 {
  int x;
  struct S1 a[10];
  struct S1 b;
} S2;

int foo (int *p, int i)
{
  int res = p[i];
  printf ("%d\n", res);
  return res;
}

struct S2 s1;
struct S2 *s2 = &s1;

int mpx_test (int argc, const char **argv)
{
  foo (&(s2->a[0].a), 0);
  foo (&(s2->a[9].c), 0);

  return 0;
}