1 /* PR middle-end/10138 - warn for uninitialized arrays passed as const*
3 Verify that passing pointers to uninitialized objects to arguments
4 to functions declared with attribute access is diagnosed where expected.
6 { dg-options "-O -Wall" } */
8 #define RW(...) __attribute__ ((access (read_write, __VA_ARGS__)))
11 f4pi (int*, int*, int*, int*); // { dg-message "in a call to 'f4pi' declared with attribute 'access \\\(read_write, \[13\]\\\)'" }
14 void nowarn_scalar (void)
16 int i1
= 0, i2
, i3
= 1, i4
;
17 f4pi (&i1
, &i2
, &i3
, &i4
);
20 void warn_scalar_1 (void)
22 int i1
; // { dg-message "declared here" }
25 f4pi (&i1
, &i2
, &i3
, &i4
); // { dg-warning "'i1' may be used uninitialized" }
28 void warn_scalar_2 (void)
33 f4pi (&j1
, &j2
, &j3
, &j4
); // { dg-warning "'j3' may be used uninitialized" }
37 void nowarn_array_init (void)
39 int a1
[4] = { 0 }, a2
[5], a3
[6] = { 0 }, a4
[7];
41 f4pi (a1
, a2
, a3
, a4
);
44 void warn_array_1 (void)
46 int a1
[4]; // { dg-message "'a1' declared here" }
47 int a2
[5], a3
[6] = { 0 }, a4
[7];
49 f4pi (a1
, a2
, a3
, a4
); // { dg-warning "'a1' may be used uninitialized" }
52 void warn_array_2 (void)
54 int a1
[4] = { 0 }, a2
[5], a4
[7];
55 int a3
[6]; // { dg-message "'a3' declared here" }
57 f4pi (a1
, a2
, a3
, a4
); // { dg-warning "'a3' may be used uninitialized" }