File: Warray-bounds-91.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (145 lines) | stat: -rw-r--r-- 4,780 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* PR middle-end/103215 - bogus -Warray-bounds with two pointers with
   different offsets each
   Test for accesses into the same array through pointers with different
   offsets each.
   { dg-do compile }
   { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */

#define NOIPA __attribute__ ((noipa))

#define A(p, off) ((p)[off] = __COUNTER__)

extern int a4[4];


NOIPA void p0_p1 (int i)
{
  int *p0 = a4 + 0;
  int *p1 = a4 + 1;
  int *q = i ? p0 : p1;
  A (q, -2);      // { dg-warning "-Warray-bounds" }
  A (q, -1); A (q, 0); A (q, 1); A (q, 2);
  /* Since q points to a4 and -1 is a valid subscript, +3 must be invalid.
     But the warning for each subscript is independent of prior subscripts
     into the same object.  That should be improved.  */
  A (q, 3);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 4);       // { dg-warning "-Warray-bounds" }
}

NOIPA void p1_p0 (int i)
{
  int *p1 = a4 + 1;
  int *p0 = a4 + 0;
  int *q = i ? p0 : p1;
  A (q, -2);      // { dg-warning "-Warray-bounds" }
  A (q, -1); A (q, 0); A (q, 1); A (q, 2);
  A (q, 3);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 4);       // { dg-warning "-Warray-bounds" }
}


NOIPA void p1_p2 (int i)
{
  int *p1 = a4 + 1;
  int *p2 = a4 + 2;
  int *q = i ? p1 : p2;
  A (q, -3);      // { dg-warning "-Warray-bounds" }
  A (q, -2); A (q, -1); A (q, 0); A (q, 1);
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" }
}

NOIPA void p2_p1 (int i)
{
  int *p2 = a4 + 2;
  int *p1 = a4 + 1;
  int *q = i ? p1 : p2;
  A (q, -3);      // { dg-warning "-Warray-bounds" }
  A (q, -2); A (q, -1); A (q, 0); A (q, 1);
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" }
}


NOIPA void p1_p3 (int i)
{
  int *p1 = a4 + 1;
  int *p3 = a4 + 3;
  int *q = i ? p1 : p3;
  A (q, -4);      // { dg-warning "-Warray-bounds" }
  A (q, -3); A (q, -2); A (q, -1); A (q, 0);
  A (q, 1);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" }
}

NOIPA void p3_p1 (int i)
{
  int *p3 = a4 + 3;
  int *p1 = a4 + 1;
  int *q = i ? p1 : p3;
  A (q, -4);      // { dg-warning "-Warray-bounds" }
  A (q, -3); A (q, -2); A (q, -1); A (q, 0);
  A (q, 1);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" }
}


NOIPA void p1_p4 (int i)
{
  int *p1 = a4 + 1;
  int *p4 = a4 + 4;
  int *q = i ? p1 : p4;
  A (q, -5);      // { dg-warning "-Warray-bounds" }
  A (q, -4); A (q, -3); A (q, -2); A (q, -1);
  A (q, 0);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 1);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" }
}

NOIPA void p4_p1 (int i)
{
  int *p4 = a4 + 4;
  int *p1 = a4 + 1;
  int *q = i ? p1 : p4;
  A (q, -5);      // { dg-warning "-Warray-bounds" }
  A (q, -4); A (q, -3); A (q, -2); A (q, -1);
  A (q, 0);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 1);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" }
}


NOIPA void p0_p1_p2 (int i)
{
  int *p0 = a4 + 0;
  int *p1 = a4 + 1;
  int *p2 = a4 + 2;
  int *q = i < 0 ? p1 : 0 < i ? p2 : p0;
  A (q, -3);      // { dg-warning "-Warray-bounds" }
  A (q, -2); A (q, -1); A (q, 0); A (q, 1);
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 4);       // { dg-warning "-Warray-bounds" }
}


NOIPA void p0_p1_p2_p3_p4 (int i)
{
  int *p0 = a4 + 0;
  int *p1 = a4 + 1;
  int *p2 = a4 + 2;
  int *p3 = a4 + 3;
  int *p4 = a4 + 4;
  int *q = i < -1 ? p1 : i < 0 ? p2 : 1 < i ? p4 : 0 < i ? p3 : p0;
  A (q, -5);      // { dg-warning "-Warray-bounds" }
  A (q, -4); A (q, -3); A (q, -2); A (q, -1);
  A (q, 0);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 1);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 2);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 3);       // { dg-warning "-Warray-bounds" "pr??????" { xfail *-*-* } }
  A (q, 4);       // { dg-warning "-Warray-bounds" }
}