]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/attr-alloc_size-12.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / attr-alloc_size-12.c
CommitLineData
1d249509
MS
1/* PR middle-end/81871 - bogus attribute alloc_align accepted
2 Test exercising the problem with attribute alloc_size.
3 { dg-do compile }
4 { dg-options "-Wall" } */
5
6#define ASIZE(...) __attribute__ ((alloc_size (__VA_ARGS__)))
7#define SIZE_MAX __SIZE_MAX__
8
9ASIZE (-1) void fvv_m1 (void); /* { dg-warning ".alloc_size. attribute ignored on a function returning .void." } */
10
11ASIZE (1) int fiv_1 (void); /* { dg-warning ".alloc_size. attribute ignored on a function returning .int." } */
12
13ASIZE (1, 2) int fiv_1_2 (void); /* { dg-warning ".alloc_size. attribute ignored on a function returning .int." } */
14
15ASIZE (0) void* fpvv_0 (void); /* { dg-warning ".alloc_size. attribute argument value .0. does not refer to a function parameter" } */
16
17ASIZE (1, 0) void*
18fpvv_1_0 (int); /* { dg-warning ".alloc_size. attribute argument 2 value .0. does not refer to a function parameter" } */
19
20ASIZE (1) void* fpvv_1 (void); /* { dg-warning ".alloc_size. attribute argument value .1. exceeds the number of function parameters 0" } */
21
22ASIZE (1, 9) void*
23fpvv_1_9 (int); /* { dg-warning ".alloc_size. attribute argument 2 value .9. exceeds the number of function parameters 1" } */
24
25ASIZE (2) void* fii_2 (int); /* { dg-warning ".alloc_size. attribute argument value .2. exceeds the number of function parameters 1" } */
26
27ASIZE (1) void fvi_1 (int); /* { dg-warning ".alloc_size. attribute ignored on a function returning .void." } */
28
29/* Using alloc_size with a function returning a pointer to a function
30 should perhaps trigger a warning. */
31typedef void (F)(void);
32ASIZE (1) F* fpF_i_1 (int);
33
34ASIZE (SIZE_MAX) void*
35fpvi_szmax (int); /* { dg-warning ".alloc_size. attribute argument value .\[0-9\]+. exceeds the number of function parameters 1" } */
36
37ASIZE ("12") void*
38fpvi_str_1 (int); /* { dg-warning ".alloc_size. attribute argument has type .char\\\[3]." } */
39
40ASIZE (1, "123") void*
41fpvi_str_2 (int, int); /* { dg-warning ".alloc_size. attribute argument 2 has type .char\\\[4]." } */
42
43ASIZE ((void*)0) void*
44fpvi_pv0 (int); /* { dg-warning ".alloc_size. attribute argument has type .void \\\*." } */
45
46ASIZE ((double*)sizeof (double)) void*
47fpvi_pd1 (int); /* { dg-warning ".alloc_size. attribute argument has type .double \\\*." } */
48
49ASIZE (1) void*
50fpvi_pv_1 (void*); /* { dg-warning ".alloc_size. attribute argument value .1. refers to parameter type .void \\\*." } */
51
52struct S { int i; };
53ASIZE (2) void*
54fpvi_S_2 (int, struct S); /* { dg-warning ".alloc_size. attribute argument value .2. refers to parameter type .struct S." } */
55
56ASIZE ((struct S){ 1 }) void*
57fpvi_S (int); /* { dg-warning ".alloc_size. attribute argument has type .struct S." } */
58
59ASIZE (1, (struct S){ 1 }) void*
60fpvi_1_S (int); /* { dg-warning ".alloc_size. attribute argument 2 has type .struct S." } */