1 /* PR middle-end/81824 - Warn for missing attributes with function aliases
3 { dg-require-alias "" }
4 { dg-options "-Wall" } */
6 #define ATTR(list) __attribute__ (list)
9 int alias_no_const (void);
12 target_const (void) /* { dg-message ".alias_no_const. target declared here" } */
15 ATTR ((alias ("target_const"))) int
16 alias_no_const (void); /* { dg-warning ".alias_no_const. specifies less restrictive attribute than its target .target_const.: .const." } */
19 ATTR ((alloc_size (1), malloc
)) void*
20 target_malloc (int n
) /* { dg-message ".alias_no_malloc. target declared here" } */
21 { return __builtin_malloc (n
); }
23 ATTR ((alias ("target_malloc"))) void*
24 alias_no_malloc (int); /* { dg-warning ".alias_no_malloc. specifies less restrictive attributes than its target .target_malloc.: .alloc_size., .malloc." } */
28 target_leaf (void) /* { dg-message ".alias_no_leaf. target declared here" } */
31 ATTR ((alias ("target_leaf"))) int
32 alias_no_leaf (void); /* { dg-warning ".alias_no_leaf. specifies less restrictive attribute than its target .target_leaf.: .leaf." } */
35 /* Verify that attributes noclone, noinline, and noipa on the target
36 don't cause a warning for aliases without the attribute. */
42 ATTR ((alias ("target_noclone"))) int
43 alias_no_noclone (void);
50 ATTR ((alias ("target_noipa"))) int
51 alias_no_noipa (void);
55 target_noinline (void)
58 ATTR ((alias ("target_noinline"))) int
59 alias_no_noinline (void);
63 target_nothrow (void) /* { dg-message ".alias_no_nothrow. target declared here" } */
66 ATTR ((alias ("target_nothrow"))) int
67 alias_no_nothrow (void); /* { dg-warning ".alias_no_nothrow. specifies less restrictive attribute than its target .target_nothrow.: .nothrow." } */
70 /* Verify that attribute weak on the target doesn't cause and isn't
71 mentioned in a warning for aliases without the attribute. */
77 ATTR ((alias ("target_weak"))) int
81 ATTR ((nothrow
, weak
)) int
82 target_nothrow_weak (void) /* { dg-message ".alias_nothrow_no_weak. target declared here" } */
85 ATTR ((alias ("target_nothrow_weak"))) int
86 alias_nothrow_no_weak (void); /* { dg-warning ".alias_nothrow_no_weak. specifies less restrictive attribute than its target .target_nothrow_weak.: .nothrow." } */
89 /* Verify that __typeof__ doesn't include attributes. */
95 __typeof__ (target_cold
) ATTR ((alias ("target_cold")))
96 alias_cold
; /* { dg-warning ".alias_cold. specifies less restrictive attribute than its target .target_cold.: .cold." } */