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+
65
76
87/*********************************************************************************/
@@ -16,7 +15,7 @@ through invalid pointer arithmetic, an unsafe cast, etc.*/
1615/*********************************************************************************/
1716
1817
19- #define size_t int
18+ typedef unsigned long size_t ;
2019#define NULL 0
2120extern _Itype_for_any (T ) void * calloc (size_t nmemb , size_t size ) : itype (_Array_ptr < T > ) byte_count (nmemb * size );
2221extern _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 :
2827struct general {
2928 int data ;
3029 struct general * next ;
30+ //CHECK: _Ptr<struct general> next;
3131};
32- //CHECK_NOALL: _Ptr<struct general> next;
33-
34- //CHECK_ALL: _Ptr<struct general> next;
35-
3632
3733struct warr {
3834 int data1 [5 ];
35+ //CHECK_NOALL: int data1[5];
36+ //CHECK_ALL: int data1 _Checked[5];
3937 char * name ;
38+ //CHECK: _Ptr<char> name;
4039};
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-
4740
4841struct fptrarr {
4942 int * values ;
43+ //CHECK: _Ptr<int> values;
5044 char * name ;
45+ //CHECK: _Ptr<char> name;
5146 int (* mapper )(int );
47+ //CHECK: _Ptr<int (int )> mapper;
5248};
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-
6149
6250struct fptr {
6351 int * value ;
52+ //CHECK: _Ptr<int> value;
6453 int (* func )(int );
54+ //CHECK: _Ptr<int (int )> func;
6555};
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-
7256
7357struct arrfptr {
7458 int args [5 ];
59+ //CHECK_NOALL: int args[5];
60+ //CHECK_ALL: int args _Checked[5];
7561 int (* funcs [5 ]) (int );
62+ //CHECK_NOALL: int (*funcs[5]) (int);
63+ //CHECK_ALL: _Ptr<int (int )> funcs _Checked[5];
7664};
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-
8365
8466int add1 (int x ) {
8567 return x + 1 ;
@@ -107,54 +89,49 @@ int zerohuh(int n) {
10789}
10890
10991int * mul2 (int * x ) {
92+ //CHECK: _Ptr<int> mul2(_Ptr<int> x) {
11093 * x *= 2 ;
11194 return x ;
11295}
11396
114- //CHECK_NOALL: _Ptr<int> mul2(_Ptr<int> x) {
115-
116- //CHECK_ALL: _Ptr<int> mul2(_Ptr<int> x) {
117-
11897int * 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) {
119100x = (int * ) 5 ;
101+ //CHECK: x = (int *) 5;
120102 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);
122109 for (i = 0 , p = z , fac = 1 ; i < 5 ; ++ i , p ++ , fac *= i )
123110 { * p = fac ; }
124111z += 2 ;
125112return 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);
132113
133114int * foo () {
115+ //CHECK_NOALL: int * foo(void) {
116+ //CHECK_ALL: _Nt_array_ptr<int> foo(void) {
134117 int * x = malloc (sizeof (int ));
118+ //CHECK: int * x = malloc<int>(sizeof(int));
135119 int * y = malloc (sizeof (int ));
120+ //CHECK: _Ptr<int> y = malloc<int>(sizeof(int));
136121 int * z = sus (x , y );
122+ //CHECK_NOALL: int * z = sus(x, y);
123+ //CHECK_ALL: _Nt_array_ptr<int> z = sus(x, y);
137124return 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);
146125
147126int * bar () {
127+ //CHECK_NOALL: int * bar(void) {
128+ //CHECK_ALL: _Nt_array_ptr<int> bar(void) {
148129 int * x = malloc (sizeof (int ));
130+ //CHECK: int * x = malloc<int>(sizeof(int));
149131 int * y = malloc (sizeof (int ));
132+ //CHECK: _Ptr<int> y = malloc<int>(sizeof(int));
150133 int * z = sus (x , y );
134+ //CHECK_NOALL: int * z = sus(x, y);
135+ //CHECK_ALL: _Nt_array_ptr<int> z = sus(x, y);
151136z += 2 ;
152137return 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