1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
/* run.config*
EXIT: 1
STDOPT:
*/
// In this file, each write raises an error: writing non-ghost memory location
// from ghost code, except if a comment says the opposite.
struct Type {
int field ;
} ;
void direct(void){
int ng ;
/*@ ghost ng = 42 ; */
}
void ptr_access(void){
int ng ;
//@ ghost int * ptr = &ng ;
//@ ghost *ptr = 42 ;
}
void in_struct(void){
struct Type ng_var ;
//@ ghost ng_var.field = 42 ;
}
void nesting(void){
/*@ ghost
int * * ptrp ;
int * \ghost * ptrpg ;
int * arrp[10] ;
int (* ptra)[10] ;
*/
/*@ ghost
*ptrp = (void *) 0 ;
**ptrp = 1 ;
**ptrpg = 1 ;
*arrp[0] = 1 ;
(*ptra)[0] = 1 ;
*/
}
/*@ ghost
/@ assigns *a ; @/
void decl_invalid_a(int * a) ;
void decl_invalid_no_assigns (void);
*/
/*@ ghost
void def_invalid_a(int * a){
*a = 42 ;
decl_invalid_a(a); // should not raise an error as the problem is in `decl_invalid_a`
}
*/
void assigns_clause(void){
int p ;
/*@ ghost
/@ loop assigns p, i ; @/
for(int i = 0; i < 10; i++);
*/
}
/*@ ghost
/@ assigns *p ; @/
void g_decl_star(int *p);
/@ assigns *p ; @/
void g_def_star(int *p){
}
*/
void assigns_loop_star(){
//@ ghost int *p ;
/*@ ghost
/@ loop assigns *p, i ; @/
for(int i = 0; i < 10; i++);
*/
}
/*@ ghost
/@ assigns p[ 0 .. max ] ; @/
void g_decl_set(int *p, int max);
/@ assigns p[ 0 .. max ] ; @/
void g_def_set(int *p, int max){
}
*/
void assigns_loop_set(){
//@ ghost int *p ;
int max = 10 ; // this is valid
/*@ ghost
/@ loop assigns p[ 0 .. max ], i ; @/
for(int i = 0; i < 10; i++);
*/
}
/*@ assigns *a ; */
void assigns_parameter(int* a);
void no_assign_specification(int* a);
/*@ assigns *a ; */
int int_assigns_parameter(int* a);
int int_no_assign_specification(int* a);
void def_no_assign_spec(void){
}
int int_def_no_assign_spec(void){
return 42;
}
void calls(void){
int ng ;
/*@ ghost
assigns_parameter(&ng);
no_assign_specification(&ng);
def_no_assign_spec();
*/
/*@ ghost
int x1 = int_assigns_parameter(&ng);
int x2 = int_no_assign_specification(&ng);
int x3 = int_def_no_assign_spec();
*/
}
/*@ assigns \nothing ; */
void assigns_nothing(int* a);
/*@ assigns \nothing ; */
int int_assigns_nothing(int* a);
/*@ assigns *a ; */
void assigns_parameter(int* a);
/*@ assigns *a ; */
int int_assigns_parameter(int* a);
void ghost_calls_to_non_ghost_functions(){
int ng ;
//@ ghost int g ;
/*@ ghost
assigns_nothing(&ng);
assigns_nothing(&g);
assigns_parameter(&g);
*/
/*@ ghost
int x1 = int_assigns_nothing(&ng);
int x2 = int_assigns_nothing(&g);
int x3 = int_assigns_parameter(&g);
*/
}
|