Print this page
new smatch
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/validation/typeof-mods.c
+++ new/usr/src/tools/smatch/src/validation/typeof-mods.c
1 1 #define __noderef __attribute__((noderef))
2 2 #define __bitwise __attribute__((bitwise))
3 3 #define __nocast __attribute__((nocast))
4 4 #define __safe __attribute__((safe))
5 5
6 6 static void test_spec(void)
7 7 {
8 8 unsigned int obj, *ptr;
9 9 typeof(obj) var = obj;
10 10 typeof(ptr) ptr2 = ptr;
11 11 typeof(*ptr) var2 = obj;
12 12 typeof(*ptr) *ptr3 = ptr;
13 13 typeof(obj) *ptr4 = ptr;
14 14 obj = obj;
15 15 ptr = ptr;
16 16 ptr = &obj;
17 17 obj = *ptr;
18 18 }
19 19
20 20 static void test_const(void)
21 21 {
22 22 const int obj, *ptr;
23 23 typeof(obj) var = obj;
24 24 typeof(ptr) ptr2 = ptr;
25 25 typeof(*ptr) var2 = obj;
26 26 typeof(*ptr) *ptr3 = ptr;
27 27 typeof(obj) *ptr4 = ptr;
28 28 ptr = ptr;
29 29 ptr = &obj;
30 30 }
31 31
32 32 static void test_volatile(void)
33 33 {
34 34 volatile int obj, *ptr;
35 35 typeof(obj) var = obj;
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
36 36 typeof(ptr) ptr2 = ptr;
37 37 typeof(*ptr) var2 = obj;
38 38 typeof(*ptr) *ptr3 = ptr;
39 39 typeof(obj) *ptr4 = ptr;
40 40 obj = obj;
41 41 ptr = ptr;
42 42 ptr = &obj;
43 43 obj = *ptr;
44 44 }
45 45
46 +static void test_restrict(void)
47 +{
48 + int *restrict obj, *restrict *ptr;
49 + typeof(obj) var = obj;
50 + typeof(ptr) ptr2 = ptr;
51 + typeof(*ptr) var2 = obj;
52 + typeof(*ptr) *ptr3 = ptr;
53 + typeof(obj) *ptr4 = ptr;
54 + obj = obj;
55 + ptr = ptr;
56 + ptr = &obj;
57 + obj = *ptr;
58 +}
59 +
60 +static void test_atomic(void)
61 +{
62 + int _Atomic obj, *ptr;
63 + typeof(obj) var = obj;
64 + typeof(ptr) ptr2 = ptr;
65 + typeof(*ptr) var2 = obj;
66 + typeof(*ptr) *ptr3 = ptr;
67 + typeof(obj) *ptr4 = ptr;
68 + obj = obj;
69 + ptr = ptr;
70 + ptr = &obj;
71 + obj = *ptr;
72 +}
73 +
46 74 static void test_bitwise(void)
47 75 {
48 76 typedef int __bitwise type_t;
49 77 type_t obj, *ptr;
50 78 typeof(obj) var = obj;
51 79 typeof(ptr) ptr2 = ptr;
52 80 typeof(*ptr) var2 = obj;
53 81 typeof(*ptr) *ptr3 = ptr;
54 82 typeof(obj) *ptr4 = ptr;
55 83 obj = obj;
56 84 ptr = ptr;
57 85 ptr = &obj;
58 86 obj = *ptr;
59 87 }
60 88
61 89 static void test_static(void)
62 90 {
63 91 static int obj, *ptr;
64 92 typeof(obj) var = obj;
65 93 typeof(ptr) ptr2 = ptr;
66 94 typeof(*ptr) var2 = obj;
67 95 typeof(*ptr) *ptr3 = ptr;
68 96 typeof(obj) *ptr4 = ptr;
69 97 obj = obj;
70 98 ptr = ptr;
71 99 ptr = &obj;
72 100 obj = *ptr;
73 101 }
74 102
75 103 static void test_tls(void)
76 104 {
77 105 __thread int obj, *ptr;
78 106 typeof(obj) var = obj;
79 107 typeof(ptr) ptr2 = ptr;
80 108 typeof(*ptr) var2 = obj;
81 109 typeof(*ptr) *ptr3 = ptr;
82 110 typeof(obj) *ptr4 = ptr;
83 111 obj = obj;
84 112 ptr = ptr;
85 113 ptr = &obj;
86 114 obj = *ptr;
87 115 }
88 116
89 117 static void test_nocast(void)
90 118 {
91 119 int __nocast obj, *ptr;
92 120 typeof(obj) var = obj;
93 121 typeof(ptr) ptr2 = ptr;
94 122 typeof(*ptr) var2 = obj;
95 123 typeof(*ptr) *ptr3 = ptr;
96 124 typeof(obj) *ptr4 = ptr;
97 125 obj = obj;
98 126 ptr = ptr;
99 127 ptr = &obj;
100 128 obj = *ptr;
101 129 }
102 130
103 131 /*
104 132 * check-name: typeof-mods
105 133 *
106 134 * check-error-start
107 135 * check-error-end
108 136 */
↓ open down ↓ |
53 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX