summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg/attr_allocsize1.d
blob: 9efba19728961a079a887859f2e2a7c1b94c3d4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// { dg-do compile }

import gcc.attributes;

@alloc_size(1)
int ignoredfunc(int size); // { dg-warning ".alloc_size. attribute ignored on a function returning .int." }

@alloc_size(0) int var; // { dg-warning ".alloc_size. attribute only applies to function types" }

@attribute("alloc_size", "1")
void* invalid1(int size); // { dg-warning ".alloc_size. attribute argument is invalid" }

@attribute("alloc_size", 1, "2")
void* invalid2(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 is invalid" }

@attribute("alloc_size", 0.1)
void* wrongtype1(int size); // { dg-warning ".alloc_size. attribute argument has type .double." }

@attribute("alloc_size", 1, 0.2)
void* wrongtype2(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 has type .double." }

@alloc_size(0)
void* malloc0(int size); // { dg-warning ".alloc_size. attribute argument value .0. does not refer to a function parameter" }

@alloc_size(1, 0)
void* malloc0(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 value .0. does not refer to a function parameter" }

@alloc_size(1, 0, true)
void* malloc0pos(int count, int size);

@alloc_size(1, -1, true)
void* mallocminus1(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 value .-1. does not refer to a function parameter" }

@alloc_size(99)
void* malloc99(int size); // { dg-warning ".alloc_size. attribute argument value .99. exceeds the number of function parameters 1" }

@alloc_size(1, 99)
void* malloc99(int count, int size); // { dg-warning ".alloc_size. attribute argument 2 value .99. exceeds the number of function parameters 2" }

@alloc_size(1)
void* mallocdouble(double size); // { dg-warning ".alloc_size. attribute argument value .1. refers to parameter type .double." }

@alloc_size(2, 1)
void* mallocdouble(int count, double size); // { dg-warning ".alloc_size. attribute argument 1 value .2. refers to parameter type .double." }