main
test-branch
|
Last change
on this file since bd7a43e 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:
829 bytes
|
| Line | |
|---|
| 1 | /* civlValueUndefined : This example lists several cases of misusage of
|
|---|
| 2 | $scope, $proc and pointer types. It is used for code coverage, so
|
|---|
| 3 | the program may not meaningful. */
|
|---|
| 4 | #include<civlc.cvh>
|
|---|
| 5 | #include<stdlib.h>
|
|---|
| 6 | $scope scope;
|
|---|
| 7 | double * ptr;
|
|---|
| 8 |
|
|---|
| 9 | int dummy(int x);
|
|---|
| 10 | $scope root = $here;
|
|---|
| 11 |
|
|---|
| 12 | void getInvalidScope() {
|
|---|
| 13 | scope = $here;
|
|---|
| 14 | ptr = (double*)malloc(sizeof(double));
|
|---|
| 15 | free(ptr);
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | int main() {
|
|---|
| 19 | $proc proc0, proc1;
|
|---|
| 20 | int a = 0;
|
|---|
| 21 |
|
|---|
| 22 | proc0 = $spawn getInvalidScope();
|
|---|
| 23 | $wait(proc0);
|
|---|
| 24 | proc1 = proc0;
|
|---|
| 25 | //so far, scope, proc0 and proc1 are all undefined; ptr is to a
|
|---|
| 26 | //memory space which belongs to an undefined scope.
|
|---|
| 27 | //And, the function dummy() is "undefined" too: it only has a declaration.
|
|---|
| 28 | $choose{
|
|---|
| 29 | {a = scope == root;}
|
|---|
| 30 | {a = proc0 == proc1;}
|
|---|
| 31 | {a = ptr == (void*)0;}
|
|---|
| 32 | {a = dummy(a);};
|
|---|
| 33 | }
|
|---|
| 34 | return 0;
|
|---|
| 35 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.