1 /* PR middle-end/81871 - bogus attribute alloc_align accepted
2 { dg-do compile }
3 { dg-options "-Wall" } */
4
5 #define ALIGN(N) __attribute__ ((alloc_align (N)))
6 #define SIZE_MAX __SIZE_MAX__
7
8 ALIGN (1) void fvv_m1 (void); /* { dg-warning ".alloc_align. attribute ignored on a function returning .void." } */
9
10 ALIGN (1) int fiv_1 (void); /* { dg-warning ".alloc_align. attribute ignored on a function returning .int." } */
11
12 ALIGN (0) void* fpvv_0 (void); /* { dg-warning ".alloc_align. attribute argument value .0. does not refer to a function parameter" } */
13
14 ALIGN (1) void* fpvv_1 (void); /* { dg-warning ".alloc_align. attribute argument value .1. exceeds the number of function parameters 0" } */
15
16 ALIGN (2) void* fii_2 (int); /* { dg-warning ".alloc_align. attribute argument value .2. exceeds the number of function parameters 1" } */
17
18 ALIGN (1) void fvi_1 (int); /* { dg-warning ".alloc_align. attribute ignored on a function returning .void." } */
19
20 /* Using alloc_align with a function returning a pointer to a function
21 should perhaps trigger a warning. */
22 typedef void (F)(void);
23 ALIGN (1) F* fpF_i_1 (int);
24
25 ALIGN (SIZE_MAX) void*
26 fpvi_szmax (int); /* { dg-warning ".alloc_align. attribute argument value .\[0-9\]+. exceeds the number of function parameters 1" } */
27
28 ALIGN ("1") void*
29 fpvi_str_1 (int); /* { dg-warning ".alloc_align. attribute argument has type .char\\\[2]" } */
30
31 ALIGN ((void*)0) void*
32 fpvi_pv0 (int); /* { dg-warning ".alloc_align. attribute argument has type .void \\\*." } */
33
34 ALIGN ((double*)1) void*
35 fpvi_pd1 (int); /* { dg-warning ".alloc_align. attribute argument has type .double \\\*." } */
36
37 ALIGN (1) void*
38 fpvi_pv_1 (void*); /* { dg-warning ".alloc_align. attribute argument value .1. refers to parameter type .void \\\*." } */
39
40 struct S { int i; };
41 ALIGN (2) void*
42 fpvi_S_2 (int, struct S); /* { dg-warning ".alloc_align. attribute argument value .2. refers to parameter type .struct S." } */
43