| 1 |
/* PR middle-end/101751 - attribute access none with void pointer expects |
| 2 |
nonzero size |
| 3 |
{ dg-do compile } |
| 4 |
{ dg-options "-Wall" } */ |
| 5 |
|
| 6 |
__attribute__ ((access (none, 1))) void |
| 7 |
fvp_m1 (const void*); |
| 8 |
|
| 9 |
void nowarn_m1 (void) |
| 10 |
{ |
| 11 |
/* Verify these don't trigger a warning for calls to a function |
| 12 |
declared with attribute access none. */ |
| 13 |
fvp_m1 ((void*)-1); // { dg-bogus "-Wstringop-" } |
| 14 |
fvp_m1 ((void*)1); // { dg-bogus "-Wstringop-" } |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
__attribute__ ((access (none, 1))) void |
| 19 |
fvp_none (void*); |
| 20 |
|
| 21 |
void nowarn_c_cp1 (void) |
| 22 |
{ |
| 23 |
char c; |
| 24 |
fvp_none (&c); |
| 25 |
fvp_none (&c + 1); // { dg-bogus "-Wstringop-" } |
| 26 |
} |
| 27 |
|
| 28 |
void nowarn_f_fp1 (void) |
| 29 |
{ |
| 30 |
fvp_none ((char*)&nowarn_f_fp1); |
| 31 |
fvp_none ((char*)&nowarn_f_fp1 + 1); |
| 32 |
} |
| 33 |
|
| 34 |
void nowarn_sp1_sp_4 (void) |
| 35 |
{ |
| 36 |
fvp_none ("" + 1); // { dg-bogus "-Wstringop-" } |
| 37 |
fvp_none ("123" + 4); // { dg-bogus "-Wstringop-" } |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
__attribute__ ((access (none, 1))) void |
| 42 |
wfvp_none (void*); // { dg-message "in a call to function 'wfvp_none' declared with attribute 'access \\\(none, 1\\\)'" } |
| 43 |
|
| 44 |
void warn_cm1_p1 (void) |
| 45 |
{ |
| 46 |
char c; |
| 47 |
/* With optimization both of the following are diagnosed by -Warray-bounds. |
| 48 |
The second also without optimization by -Wstringop-overread. They |
| 49 |
should both be diagnosed by the same warning even without optimization. */ |
| 50 |
wfvp_none (&c - 1); // { dg-warning "" "pr??????" { xfail *-*-* } } |
| 51 |
wfvp_none (&c + 2); // { dg-warning "" } |
| 52 |
} |
| 53 |
|
| 54 |
void warn_fp2 (void) |
| 55 |
{ |
| 56 |
void *p = (char*)&warn_fp2 + sizeof warn_fp2; |
| 57 |
fvp_none (p); // { dg-warning "" "pr??????" { xfail *-*-* } } |
| 58 |
} |
| 59 |
|
| 60 |
void warn_sp2 (void) |
| 61 |
{ |
| 62 |
wfvp_none ("" + 2); // { dg-warning "" } |
| 63 |
} |