comparison gcc/testsuite/gcc.dg/Wmissing-attributes.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* PR middle-end/81824 - Warn for missing attributes with function aliases
2 { dg-do compile }
3 { dg-require-alias "" }
4 { dg-options "-Wall" } */
5
6 #define ATTR(list) __attribute__ (list)
7
8
9 int alias_no_const (void);
10
11 ATTR ((const)) int
12 target_const (void) /* { dg-message ".alias_no_const. target declared here" } */
13 { return 0; }
14
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." } */
17
18
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); }
22
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." } */
25
26
27 ATTR ((leaf)) int
28 target_leaf (void) /* { dg-message ".alias_no_leaf. target declared here" } */
29 { return 0; }
30
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." } */
33
34
35 /* Verify that attributes noclone, noinline, and noipa on the target
36 don't cause a warning for aliases without the attribute. */
37
38 ATTR ((noclone)) int
39 target_noclone (void)
40 { return 0; }
41
42 ATTR ((alias ("target_noclone"))) int
43 alias_no_noclone (void);
44
45
46 ATTR ((noipa)) int
47 target_noipa (void)
48 { return 0; }
49
50 ATTR ((alias ("target_noipa"))) int
51 alias_no_noipa (void);
52
53
54 ATTR ((noinline)) int
55 target_noinline (void)
56 { return 0; }
57
58 ATTR ((alias ("target_noinline"))) int
59 alias_no_noinline (void);
60
61
62 ATTR ((nothrow)) int
63 target_nothrow (void) /* { dg-message ".alias_no_nothrow. target declared here" } */
64 { return 0; }
65
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." } */
68
69
70 /* Verify that attribute weak on the target doesn't cause and isn't
71 mentioned in a warning for aliases without the attribute. */
72
73 ATTR ((weak)) int
74 target_weak (void)
75 { return 0; }
76
77 ATTR ((alias ("target_weak"))) int
78 alias_no_weak (void);
79
80
81 ATTR ((nothrow, weak)) int
82 target_nothrow_weak (void) /* { dg-message ".alias_nothrow_no_weak. target declared here" } */
83 { return 0; }
84
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." } */
87
88
89 /* Verify that __typeof__ doesn't include attributes. */
90
91 ATTR ((cold)) int
92 target_cold (void)
93 { return 0; }
94
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." } */