1 /* PR c/81566 - invalid attribute aligned accepted on functions
2 { dg-do compile }
3 { dg-options "-Wall -Wattributes -ftrack-macro-expansion=0" } */
4
5 #define ATTR(list) __attribute__ (list)
6 #define ALIGN(n) ATTR ((aligned (n)))
7
8 /* It's okay to increase the alignment of a function. */
9
10 void ALIGN (16) ALIGN (32)
11 falign32_1 (void);
12
13 void ALIGN (16) falign32_2 (void);
14 void ALIGN (32) falign32_2 (void);
15
16 void falign32_2 (void) { }
17
18 void ALIGN (32) falign32_2 (void);
19
20 /* It's not okay to decrease it. */
21
22 void ALIGN (32) ALIGN (16)
23 falign64_3 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
24
25 void ALIGN (32)
26 falign64_3 (void);
27
28 void falign64_3 (void);
29
30 void falign64_3 (void) { }
31
32
33 void ALIGN (32)
34 falign64_4 (void); /* { dg-message "previous declaration here" } */
35
36 void ALIGN (16)
37 falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
38
39 void ALIGN (32)
40 falign64_4 (void); /* { dg-message "previous declaration here" } */
41
42 void ALIGN (16)
43 falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */
44
45 void ALIGN (64)
46 falign64_4 (void);
47
48 void ALIGN (32)
49 falign64_4 (void); /* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." } */
50
51 void falign64_4 (void);
52
53 void ALIGN (64)
54 falign64_4 (void) { }
55
56 void falign64_4 (void);
57
58 void ALIGN (64)
59 falign64_4 (void);
60
61
62 void ATTR ((aligned (16), aligned (32)))
63 falign64_5 (void);
64
65 void ATTR ((aligned (32), aligned (64)))
66 falign64_5 (void);
67
68 void ATTR ((aligned (16), aligned (32), aligned (64)))
69 falign64_5 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(64\\)." } */
70 /* { dg-warning "ignoring attribute .aligned \\(32\\). because it conflicts with attribute .aligned \\(64\\)." "" { target *-*-* } .-1 } */
71
72
73 void ATTR ((aligned (16), aligned (32), aligned (16)))
74 falign64_6 (void); /* { dg-warning "ignoring attribute .aligned \\(16\\). because it conflicts with attribute .aligned \\(32\\)." } */