| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
import gcc.attributes; |
| 4 |
|
| 5 |
@alloc_size(1) |
| 6 |
int ignoredfunc(int size); // { dg-warning ".alloc_size. attribute ignored on a function returning .int." } |
| 7 |
|
| 8 |
@alloc_size(0) int var; // { dg-warning ".alloc_size. attribute only applies to function types" } |
| 9 |
|
| 10 |
@attribute("alloc_size", "1") |
| 11 |
void* invalid1(int size); // { dg-warning ".alloc_size. attribute argument is invalid" } |
| 12 |
|
| 13 |
@attribute("alloc_size", 1, "2") |
| 14 |
void* invalid2(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 is invalid" } |
| 15 |
|
| 16 |
@attribute("alloc_size", 0.1) |
| 17 |
void* wrongtype1(int size); // { dg-warning ".alloc_size. attribute argument has type .double." } |
| 18 |
|
| 19 |
@attribute("alloc_size", 1, 0.2) |
| 20 |
void* wrongtype2(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 has type .double." } |
| 21 |
|
| 22 |
@alloc_size(0) |
| 23 |
void* malloc0(int size); // { dg-warning ".alloc_size. attribute argument value .0. does not refer to a function parameter" } |
| 24 |
|
| 25 |
@alloc_size(1, 0) |
| 26 |
void* malloc0(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 value .0. does not refer to a function parameter" } |
| 27 |
|
| 28 |
@alloc_size(1, 0, true) |
| 29 |
void* malloc0pos(int count, int size); |
| 30 |
|
| 31 |
@alloc_size(1, -1, true) |
| 32 |
void* mallocminus1(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 value .-1. does not refer to a function parameter" } |
| 33 |
|
| 34 |
@alloc_size(99) |
| 35 |
void* malloc99(int size); // { dg-warning ".alloc_size. attribute argument value .99. exceeds the number of function parameters 1" } |
| 36 |
|
| 37 |
@alloc_size(1, 99) |
| 38 |
void* malloc99(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 value .99. exceeds the number of function parameters 2" } |
| 39 |
|
| 40 |
@alloc_size(1) |
| 41 |
void* mallocdouble(double size); // { dg-warning ".alloc_size. attribute argument value .1. refers to parameter type .double." } |
| 42 |
|
| 43 |
@alloc_size(2, 1) |
| 44 |
void* mallocdouble(int count, double size); // { dg-warning ".alloc_size. attribute argument 1 value .2. refers to parameter type .double." } |