• Home
  • Raw
  • Download

Lines Matching +full:int +full:- +full:array

1 // RUN: %clang_cc1 -verify %s
3 int foo() { in foo()
4 int x[2]; // expected-note 4 {{array 'x' declared here}} in foo()
5 int y[2]; // expected-note 2 {{array 'y' declared here}} in foo()
6 int z[1]; // expected-note {{array 'z' declared here}} in foo()
7 int w[1][1]; // expected-note {{array 'w' declared here}} in foo()
8 int v[1][1][1]; // expected-note {{array 'v' declared here}} in foo()
9 int *p = &y[2]; // no-warning in foo()
10 (void) sizeof(x[2]); // no-warning in foo()
11 …y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 eleme… in foo()
12 …z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 ele… in foo()
13 …w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 el… in foo()
14 …v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1… in foo()
15 …return x[2] + // expected-warning {{array index 2 is past the end of the array (which contains 2 … in foo()
16 y[-1] + // expected-warning {{array index -1 is before the beginning of the array}} in foo()
17 …x[sizeof(x)] + // expected-warning {{array index 8 is past the end of the array (which contains 2… in foo()
18 …x[sizeof(x) / sizeof(x[0])] + // expected-warning {{array index 2 is past the end of the array (w… in foo()
19 x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning in foo()
20 …x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains … in foo()
23 // This code example tests that -Warray-bounds works with arrays that
29 void f1(int a[1]) { in f1()
30 int val = a[3]; // no warning for function argumnet in f1()
33 void f2(const int (&a)[2]) { // expected-note {{declared here}} in f2()
34int val = a[3]; // expected-warning {{array index 3 is past the end of the array (which contains … in f2()
39 int a[0]; in test()
41 s2.a[3] = 0; // no warning for 0-sized array in test()
44 short a[2]; // expected-note 4 {{declared here}} in test()
47 …u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 ele… in test()
50 …p = &u.a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 el… in test()
51 …*(&u.a[2]) = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2… in test()
52 …*(&u.a[3]) = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2… in test()
55 const int const_subscript = 3; in test()
56 int array[2]; // expected-note {{declared here}} in test() local
57array[const_subscript] = 0; // expected-warning {{array index 3 is past the end of the array (whi… in test()
59 int *ptr; in test()
61 int array2[] = { 0, 1, 2 }; // expected-note 2 {{declared here}} in test()
63 …array2[3] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 3 … in test()
64 …array2[2+2] = 0; // expected-warning {{array index 4 is past the end of the array (which contains … in test()
69 const char str2[] = "foo"; // expected-note {{declared here}} in test()
70 …char c2 = str2[5]; // expected-warning {{array index 5 is past the end of the array (which contain… in test()
72 int (*array_ptr)[2]; in test()
73 …(*array_ptr)[3] = 1; // expected-warning {{array index 3 is past the end of the array (which conta… in test()
76 template <int I> struct S {
77 char arr[I]; // expected-note 3 {{declared here}}
79 template <int I> void f() { in f()
81 …s.arr[4] = 0; // expected-warning 2 {{array index 4 is past the end of the array (which contains 3… in f()
82 …s.arr[I] = 0; // expected-warning {{array index 5 is past the end of the array (which contains 3 e… in f()
86 f<5>(); // expected-note {{in instantiation}} in test_templates()
92 int test_no_warn_macro_unreachable() { in test_no_warn_macro_unreachable()
93 int arr[SIZE]; // expected-note {{array 'arr' declared here}} in test_no_warn_macro_unreachable()
94 return ARR_IN_MACRO(0, arr, SIZE) + // no-warning in test_no_warn_macro_unreachable()
95 …ARR_IN_MACRO(1, arr, SIZE); // expected-warning{{array index 10 is past the end of the array (whic… in test_no_warn_macro_unreachable()
98 // This exhibited an assertion failure for a 32-bit build of Clang.
99 int test_pr9240() { in test_pr9240()
100 short array[100]; // expected-note {{array 'array' declared here}} in test_pr9240() local
101 …return array[(unsigned long long) 100]; // expected-warning {{array index 100 is past the end of t… in test_pr9240()
104 // PR 9284 - a template parameter can cause an array bounds access to be
108 int arr[3 + (extendArray ? 1 : 0)]; in pr9284()
111 arr[3] = 42; // no-warning in pr9284()
116 int arr[3 + (extendArray ? 1 : 0)]; // expected-note {{array 'arr' declared here}} in pr9284b()
119 …arr[3] = 42; // expected-warning{{array index 3 is past the end of the array (which contains 3 ele… in pr9284b()
126 …pr9284b<false>(); // expected-note{{in instantiation of function template specialization 'pr9284b<… in test_pr9284()
129 int test_pr9296() { in test_pr9296()
130 int array[2]; in test_pr9296() local
131 return array[true]; // no-warning in test_pr9296()
134 int test_sizeof_as_condition(int flag) { in test_sizeof_as_condition()
135 int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}} in test_sizeof_as_condition()
138 …ar) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index 2 is past the end of the in test_sizeof_as_condition()
144 int arr[2]; in test_switch()
145 arr[2] = 1; // no-warning in test_switch()
149 int arr[2]; // expected-note {{array 'arr' declared here}} in test_switch()
150 …arr[2] = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 ele… in test_switch()
154 int arr[2]; in test_switch()
155 arr[2] = 1; // no-warning in test_switch()
166 switch (enumA_E) { // expected-warning {{no case matching constant}} in test_nested_switch()
167 …switch (myVal) { // expected-warning {{enumeration values 'enumB_X' and 'enumB_Z' not handled in s… in test_nested_switch()
177 int x[2]; in test_all_enums_covered()
184 x[2] = 0; // no-warning in test_all_enums_covered()
189 char c1[1]; // expected-note {{declared here}}
190 int x;
196 char c1[1]; // expected-note {{declared here}}
197 int x;
202 …return F->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains… in bar()
203 F->c2[3] + // no warning, foo could have tail padding allocated. in bar()
204 …B->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 elem… in bar()
205 B->c2[3]; // no warning, baz could have tail padding allocated. in bar()
211 struct foo { char c[ONE]; }; // expected-note {{declared here}}
212 template <int N> struct bar { char c[N]; }; // expected-note {{declared here}}
215 …return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains … in test()
216 …B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 elemen… in test()
220 void bar(int x) {} in bar()
221 int test_more() { in test_more()
222 int foo[5]; // expected-note 5 {{array 'foo' declared here}} in test_more()
223 …bar(foo[5]); // expected-warning {{array index 5 is past the end of the array (which contains 5 el… in test_more()
224 …++foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 eleme… in test_more()
225 …if (foo[6]) // expected-warning {{array index 6 is past the end of the array (which contains 5 ele… in test_more()
226 …return --foo[6]; // expected-warning {{array index 6 is past the end of the array (which contains … in test_more()
228 …return foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 … in test_more()
232 double foo[4096]; // expected-note {{array 'foo' declared here}} in test_pr10771()
234 ((char*)foo)[sizeof(foo) - 1] = '\0'; // no-warning in test_pr10771()
235 *(((char*)foo) + sizeof(foo) - 1) = '\0'; // no-warning in test_pr10771()
237 …((char*)foo)[sizeof(foo)] = '\0'; // expected-warning {{array index 32768 is past the end of the in test_pr10771()
240 *(((char*)foo) + sizeof(foo)) = '\0'; // no-warning in test_pr10771()
243 int test_pr11007_aux(const char * restrict, ...);
247 double a[5]; // expected-note {{array 'a' declared here}} in test_pr11007()
248 …test_pr11007_aux("foo", a[1000]); // expected-warning {{array index 1000 is past the end of the ar… in test_pr11007()
253 int a[128]; // expected-note {{array 'a' declared here}} in test_rdar10916006()
254 a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}} in test_rdar10916006()