| 1 |
/* PR middle-end/83859 - attribute to establish relation between parameters |
| 2 |
for buffer and its size |
| 3 |
Test to verify the handling of attribute read_only combining multiple |
| 4 |
declarations of the same function. |
| 5 |
{ dg-do compile } |
| 6 |
{ dg-options "-Wall -ftrack-macro-expansion=0" } */ |
| 7 |
|
| 8 |
#define RW(...) __attribute__ ((access (read_write, __VA_ARGS__))) |
| 9 |
#define WO(...) __attribute__ ((access (write_only, __VA_ARGS__))) |
| 10 |
|
| 11 |
int rdwr1_rdwr1 (void*, void*); |
| 12 |
int RW (1) RW (1) rdwr1_rdwr1 (void*, void*); |
| 13 |
int RW (2) RW (2) rdwr1_rdwr1 (void*, void*); |
| 14 |
int RW (1) RW (2) rdwr1_rdwr1 (void*, void*); |
| 15 |
int RW (2) RW (1) rdwr1_rdwr1 (void*, void*); |
| 16 |
|
| 17 |
int frdwr1_wr1 (void*, void*); |
| 18 |
int RW (1) WO (1) frdwr1_wr1 (void*, void*); // { dg-warning "attribute 'access\\(write_only, 1\\)' mismatch with mode 'read_write'" } |
| 19 |
|
| 20 |
int RW (1) grdwr1_wr1 (void*, void*); // { dg-message "previous declaration here" } |
| 21 |
|
| 22 |
int WO (1) grdwr1_wr1 (void*, void*); // { dg-warning "attribute 'access\\(write_only, 1\\)' mismatch with mode 'read_write'" } |
| 23 |
|
| 24 |
|
| 25 |
int RW (1) RW (1, 2) frdwr1_rdwr1_1 (void*, int); // { dg-warning "attribute 'access\\(read_write, 1, 2\\)' positional argument 2 missing in previous designation" } |
| 26 |
|
| 27 |
int RW (1, 2) RW (1) frdwr1_1_rdwr1 (void*, int); // { dg-warning "attribute 'access\\(read_write, 1\\)' missing positional argument 2 provided in previous designation" } |
| 28 |
|
| 29 |
int RW (1) grdwr1_rdwr1_1 (void*, int); // { dg-message "previous declaration here" } |
| 30 |
int RW (1, 2) grdwr1_rdwr1_1 (void*, int); // { dg-warning "attribute 'access\\(read_write, 1, 2\\)' positional argument 2 missing in previous designation" } |
| 31 |
|
| 32 |
|
| 33 |
typedef int *P; |
| 34 |
|
| 35 |
int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 36 |
|
| 37 |
int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 38 |
|
| 39 |
int WO(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 40 |
// { dg-warning "attribute 'access\\(write_only, 1\\)' mismatch with mode 'read_write'" "1" { target *-*-* } .-1 } |
| 41 |
|
| 42 |
int RW(1) RW(3) RW(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 43 |
// { dg-warning "attribute 'access\\(read_write, 3\\)' mismatch with mode 'write_only'" "3" { target *-*-* } .-1 } |
| 44 |
|
| 45 |
int RW(1) WO(3) WO(5) WO(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 46 |
// { dg-warning "attribute 'access\\(write_only, 5\\)' mismatch with mode 'read_write'" "5" { target *-*-* } .-1 } |
| 47 |
|
| 48 |
int RW(1) WO(3) RW(5) RW(7) RW(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 49 |
// { dg-warning "attribute 'access\\(read_write, 7\\)' mismatch with mode 'write_only'" "7" { target *-*-* } .-1 } |
| 50 |
|
| 51 |
int RW(1) WO(3) RW(5) WO(7) WO(9) WO(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 52 |
// { dg-warning "attribute 'access\\(write_only, 9\\)' mismatch with mode 'read_write'" "9" { target *-*-* } .-1 } |
| 53 |
|
| 54 |
int RW(1) WO(3) RW(5) WO(7) RW(9) RW(11) RW(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 55 |
// { dg-warning "attribute 'access\\(read_write, 11\\)' mismatch with mode 'write_only'" "11" { target *-*-* } .-1 } |
| 56 |
|
| 57 |
int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) WO(13) WO(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 58 |
// { dg-warning "attribute 'access\\(write_only, 13\\)' mismatch with mode 'read_write'" "13" { target *-*-* } .-1 } |
| 59 |
|
| 60 |
int RW(1) WO(3) RW(5) WO(7) RW(9) WO(11) RW(13) RW(15) frw1_w3_rw5_w7_rw9_wr11_rw13_w15 (P, P, P, P, P, P, P, P, P, P, P, P, P, P, P, int); |
| 61 |
// { dg-warning "attribute 'access\\(read_write, 15\\)' mismatch with mode 'write_only'" "15" { target *-*-* } .-1 } |