main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /* Commandline execution:
|
|---|
| 2 | * civl verify pointersBad.cvl
|
|---|
| 3 | * This is an example for covering some erroneous cases.
|
|---|
| 4 | * */
|
|---|
| 5 | #include<civlc.cvh>
|
|---|
| 6 | #include<pointer.cvh>
|
|---|
| 7 | #include<stdlib.h>
|
|---|
| 8 |
|
|---|
| 9 | #ifdef UNION
|
|---|
| 10 | union myStruct {
|
|---|
| 11 | int integer;
|
|---|
| 12 | double real;
|
|---|
| 13 | }number0, number1;
|
|---|
| 14 | #else
|
|---|
| 15 | struct myStruct {
|
|---|
| 16 | int integer;
|
|---|
| 17 | double real;
|
|---|
| 18 | }number0, number1;
|
|---|
| 19 | #endif
|
|---|
| 20 |
|
|---|
| 21 | $output int out;
|
|---|
| 22 | $input int X;
|
|---|
| 23 | $input int *x_ptr;
|
|---|
| 24 | void main() {
|
|---|
| 25 | int a = 0;
|
|---|
| 26 | int* b, *c;
|
|---|
| 27 | int * nilPtr = NULL;
|
|---|
| 28 | int arr0[];
|
|---|
| 29 | int arr1[X];
|
|---|
| 30 |
|
|---|
| 31 | c = (void *)(-1);
|
|---|
| 32 | b = (int *)malloc(sizeof(int));
|
|---|
| 33 | number0.integer = 0;
|
|---|
| 34 | number0.real = .1;
|
|---|
| 35 | free(b);
|
|---|
| 36 | $choose {
|
|---|
| 37 | #ifdef ICLeafNode //pointer to incomplete array
|
|---|
| 38 | {$leaf_node_ptrs(&arr1, &arr0);}
|
|---|
| 39 | #elif defined NCLeafNode //pointer to array of non-concrete extent
|
|---|
| 40 | {$leaf_node_ptrs(&arr0, &arr1);}
|
|---|
| 41 | #else
|
|---|
| 42 | {$leaf_node_ptrs(&number1, &number0);}//pointer to an object of struct type
|
|---|
| 43 | {a = *(&out);}
|
|---|
| 44 | {a = *x_ptr;}
|
|---|
| 45 | {c = &a + 1; a = *c;}
|
|---|
| 46 | {a = *c;}
|
|---|
| 47 | {a = *b;}
|
|---|
| 48 | {a = *nilPtr;}
|
|---|
| 49 | #endif
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.