source: CIVL/examples/languageFeatures/forall.cvl

main
Last change on this file was d24f3f3, checked in by Stephen Siegel <siegel@…>, 9 months ago

Committing 3 forall examples which illustrate bugs in translation
of forall. Need to add JUnit tests for them too.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5976 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 387 bytes
Line 
1#include <stdlib.h>
2
3typedef struct M {
4 int f;
5} *B;
6
7typedef struct S {
8 B g;
9} *A;
10
11int main() {
12 int n = 2;
13 A x[2];
14 for (int i = 0; i < n; i++) {
15 x[i] = (A)malloc(sizeof(struct S));
16 x[i]->g = (B)malloc(sizeof(struct M));
17 x[i]->g->f = 4;
18 }
19 $assert($forall(int i : 0 .. n - 1) x[i]->g->f == 4);
20 $for(int i: 0 .. n-1) {
21 free(x[i]->g);
22 free(x[i]);
23 }
24}
Note: See TracBrowser for help on using the repository browser.