1
- // RUN: cconv-standalone -alltypes %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL" %s
2
- //RUN: cconv-standalone %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL" %s
3
- //RUN: cconv-standalone -output-postfix=checkedNOALL %s
4
- //RUN: %clang -c %S/arrboth.checkedNOALL.c
5
- //RUN: rm %S/arrboth.checkedNOALL.c
1
+ // RUN: cconv-standalone -alltypes %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s
2
+ //RUN: cconv-standalone %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s
3
+ // RUN: cconv-standalone %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null -
4
+
6
5
7
6
8
7
/*********************************************************************************/
@@ -16,7 +15,7 @@ through invalid pointer arithmetic, an unsafe cast, etc.*/
16
15
/*********************************************************************************/
17
16
18
17
19
- #define size_t int
18
+ typedef unsigned long size_t ;
20
19
#define NULL 0
21
20
extern _Itype_for_any (T ) void * calloc (size_t nmemb , size_t size ) : itype (_Array_ptr < T > ) byte_count (nmemb * size );
22
21
extern _Itype_for_any (T ) void free (void * pointer : itype (_Array_ptr < T > ) byte_count (0 ));
@@ -28,58 +27,41 @@ extern _Unchecked char *strcpy(char * restrict dest, const char * restrict src :
28
27
struct general {
29
28
int data ;
30
29
struct general * next ;
30
+ //CHECK: _Ptr<struct general> next;
31
31
};
32
- //CHECK_NOALL: _Ptr<struct general> next;
33
-
34
- //CHECK_ALL: _Ptr<struct general> next;
35
-
36
32
37
33
struct warr {
38
34
int data1 [5 ];
35
+ //CHECK_NOALL: int data1[5];
36
+ //CHECK_ALL: int data1 _Checked[5];
39
37
char * name ;
38
+ //CHECK: _Ptr<char> name;
40
39
};
41
- //CHECK_NOALL: int data1[5];
42
- //CHECK_NOALL: _Ptr<char> name;
43
-
44
- //CHECK_ALL: int data1 _Checked[5];
45
- //CHECK_ALL: _Ptr<char> name;
46
-
47
40
48
41
struct fptrarr {
49
42
int * values ;
43
+ //CHECK: _Ptr<int> values;
50
44
char * name ;
45
+ //CHECK: _Ptr<char> name;
51
46
int (* mapper )(int );
47
+ //CHECK: _Ptr<int (int )> mapper;
52
48
};
53
- //CHECK_NOALL: _Ptr<int> values;
54
- //CHECK_NOALL: _Ptr<char> name;
55
- //CHECK_NOALL: _Ptr<int (int )> mapper;
56
-
57
- //CHECK_ALL: _Ptr<int> values;
58
- //CHECK_ALL: _Ptr<char> name;
59
- //CHECK_ALL: _Ptr<int (int )> mapper;
60
-
61
49
62
50
struct fptr {
63
51
int * value ;
52
+ //CHECK: _Ptr<int> value;
64
53
int (* func )(int );
54
+ //CHECK: _Ptr<int (int )> func;
65
55
};
66
- //CHECK_NOALL: _Ptr<int> value;
67
- //CHECK_NOALL: _Ptr<int (int )> func;
68
-
69
- //CHECK_ALL: _Ptr<int> value;
70
- //CHECK_ALL: _Ptr<int (int )> func;
71
-
72
56
73
57
struct arrfptr {
74
58
int args [5 ];
59
+ //CHECK_NOALL: int args[5];
60
+ //CHECK_ALL: int args _Checked[5];
75
61
int (* funcs [5 ]) (int );
62
+ //CHECK_NOALL: int (*funcs[5]) (int);
63
+ //CHECK_ALL: _Ptr<int (int )> funcs _Checked[5];
76
64
};
77
- //CHECK_NOALL: int args[5];
78
- //CHECK_NOALL: int (*funcs[5]) (int);
79
-
80
- //CHECK_ALL: int args _Checked[5];
81
- //CHECK_ALL: _Ptr<int (int )> funcs _Checked[5];
82
-
83
65
84
66
int add1 (int x ) {
85
67
return x + 1 ;
@@ -107,54 +89,49 @@ int zerohuh(int n) {
107
89
}
108
90
109
91
int * mul2 (int * x ) {
92
+ //CHECK: _Ptr<int> mul2(_Ptr<int> x) {
110
93
* x *= 2 ;
111
94
return x ;
112
95
}
113
96
114
- //CHECK_NOALL: _Ptr<int> mul2(_Ptr<int> x) {
115
-
116
- //CHECK_ALL: _Ptr<int> mul2(_Ptr<int> x) {
117
-
118
97
int * sus (int * x , int * y ) {
98
+ //CHECK_NOALL: int * sus(int *x, _Ptr<int> y) {
99
+ //CHECK_ALL: _Nt_array_ptr<int> sus(int *x, _Ptr<int> y) {
119
100
x = (int * ) 5 ;
101
+ //CHECK: x = (int *) 5;
120
102
int * z = calloc (5 , sizeof (int ));
121
- int i , * p , fac ;
103
+ //CHECK_NOALL: int *z = calloc<int>(5, sizeof(int));
104
+ //CHECK_ALL: _Nt_array_ptr<int> z : count(5) = calloc<int>(5, sizeof(int));
105
+ int i , fac ;
106
+ int * p ;
107
+ //CHECK_NOALL: int *p;
108
+ //CHECK_ALL: _Array_ptr<int> p : count(5) = ((void *)0);
122
109
for (i = 0 , p = z , fac = 1 ; i < 5 ; ++ i , p ++ , fac *= i )
123
110
{ * p = fac ; }
124
111
z += 2 ;
125
112
return z ; }
126
- //CHECK_NOALL: int * sus(int *x, _Ptr<int> y) {
127
- //CHECK_NOALL: int *z = calloc<int>(5, sizeof(int));
128
- //CHECK_NOALL: int i, *p, fac;
129
- //CHECK_ALL: _Nt_array_ptr<int> sus(int *x, _Ptr<int> y) {
130
- //CHECK_ALL: _Nt_array_ptr<int> z : count(5) = calloc<int>(5, sizeof(int));
131
- //CHECK_ALL: _Array_ptr<int> p : count(5) = ((void *)0);
132
113
133
114
int * foo () {
115
+ //CHECK_NOALL: int * foo(void) {
116
+ //CHECK_ALL: _Nt_array_ptr<int> foo(void) {
134
117
int * x = malloc (sizeof (int ));
118
+ //CHECK: int * x = malloc<int>(sizeof(int));
135
119
int * y = malloc (sizeof (int ));
120
+ //CHECK: _Ptr<int> y = malloc<int>(sizeof(int));
136
121
int * z = sus (x , y );
122
+ //CHECK_NOALL: int * z = sus(x, y);
123
+ //CHECK_ALL: _Nt_array_ptr<int> z = sus(x, y);
137
124
return z ; }
138
- //CHECK_NOALL: int * foo() {
139
- //CHECK_NOALL: int * x = malloc<int>(sizeof(int));
140
- //CHECK_NOALL: _Ptr<int> y = malloc<int>(sizeof(int));
141
- //CHECK_NOALL: int * z = sus(x, y);
142
- //CHECK_ALL: _Nt_array_ptr<int> foo(void) {
143
- //CHECK_ALL: int * x = malloc<int>(sizeof(int));
144
- //CHECK_ALL: _Ptr<int> y = malloc<int>(sizeof(int));
145
- //CHECK_ALL: _Nt_array_ptr<int> z = sus(x, y);
146
125
147
126
int * bar () {
127
+ //CHECK_NOALL: int * bar(void) {
128
+ //CHECK_ALL: _Nt_array_ptr<int> bar(void) {
148
129
int * x = malloc (sizeof (int ));
130
+ //CHECK: int * x = malloc<int>(sizeof(int));
149
131
int * y = malloc (sizeof (int ));
132
+ //CHECK: _Ptr<int> y = malloc<int>(sizeof(int));
150
133
int * z = sus (x , y );
134
+ //CHECK_NOALL: int * z = sus(x, y);
135
+ //CHECK_ALL: _Nt_array_ptr<int> z = sus(x, y);
151
136
z += 2 ;
152
137
return z ; }
153
- //CHECK_NOALL: int * bar() {
154
- //CHECK_NOALL: int * x = malloc<int>(sizeof(int));
155
- //CHECK_NOALL: _Ptr<int> y = malloc<int>(sizeof(int));
156
- //CHECK_NOALL: int * z = sus(x, y);
157
- //CHECK_ALL: _Nt_array_ptr<int> bar(void) {
158
- //CHECK_ALL: int * x = malloc<int>(sizeof(int));
159
- //CHECK_ALL: _Ptr<int> y = malloc<int>(sizeof(int));
160
- //CHECK_ALL: _Nt_array_ptr<int> z = sus(x, y);
0 commit comments