1 /* PR middle-end/101734 - missing warning reading from a write-only object
2 Verify that reading objects pointed to by arguments
3 declared with attribute access none or write-only is diagnosed by
6 { dg-options "-Wall" } */
8 #define A(mode, ...) __attribute__ ((access (mode, __VA_ARGS__)))
10 void sink (void *, ...);
14 int nowarn_wo_assign_r0 (int *p
, int n
)
21 int nowarn_wo_sink_r0 (int *p
, int n
)
23 sink (p
, p
+ 1, p
+ n
);
28 int warn_wo_r0 (int *p
, int n
)
30 return *p
; // { dg-warning "'\\*p' may be used uninitialized \\\[-Wmaybe-uninitialized" }
35 int nowarn_wo_w1_r1 (int *p
, int n
)
42 int warn_wo_r1 (int *p
, int n
)
44 return p
[1]; // { dg-warning "'p\\\[1]' may be used uninitialized" }
49 int nowarn_wo_rwi_rj (int *p
, int n
, int i
, int j
)
56 int warn_wo_ri (int *p
, int n
, int i
)
58 return p
[i
]; // { dg-warning " may be used uninitialized" }
64 int* nowarn_none_sink_return (int *p
, int n
)
66 sink (p
, p
+ 1, p
+ n
);
71 int warn_none_r0 (int *p
, int n
)
74 return *p
; // { dg-warning "'\\*p' may be used uninitialized" }
78 int warn_none_r1 (int *p
, int n
)
80 return p
[1]; // { dg-warning "'p\\\[1]' may be used uninitialized" }
84 int warn_none_ri (int *p
, int n
, int i
)
86 return p
[i
]; // { dg-warning " may be used uninitialized" }