1 /* { dg-do run } */
2 /* { dg-options "-fcheck-pointer-bounds -mmpx" } */
3 
4 /* { dg-additional-options "-fchkp-narrow-to-innermost-array" } */
5 
6 #include "mpx-check.h"
7 
8 struct S {
9   int first;
10   int a[10];
11   int b;
12 } S;
13 
14 struct S1 {
15   int a;
16   struct S b[10];
17   int c;
18 } S1;
19 
20 struct S2 {
21   int x;
22   struct S1 a[10];
23   struct S1 b;
24 } S2;
25 
foo(int * p,int i)26 int foo (int *p, int i)
27 {
28   int res = p[i];
29   printf ("%d\n", res);
30   return res;
31 }
32 
33 struct S2 s1;
34 struct S2 *s2 = &s1;
35 
mpx_test(int argc,const char ** argv)36 int mpx_test (int argc, const char **argv)
37 {
38   foo (&(s2->a[argc].b[5].a[0]), 0);
39   foo (&(s2->a[argc].b[5].a[0]), 9);
40 
41   return 0;
42 }
43