source: CIVL/examples/languageFeatures/dynamicStruct.cvl

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: 492 bytes
RevLine 
[36b5ada]1/* Commandline execution:
2 * civl verify dynamicStruct.cvl
3 * */
[e6b02c8]4#include <civlc.cvh>
[0d850b0]5
6void f(int n) {
7 int sum;
[48bfab9]8 $proc fp = $proc_null;
[0d850b0]9 typedef struct foo {
10 int sum;
11 int bar[n];
12 } foo;
13
14 foo s;
[ee41939]15 sum = (n * (n - 1)) / 2;
[0d850b0]16 if (n > 1) {
[48bfab9]17 fp = $spawn f(n-1);
[0d850b0]18 }
19 s.sum = 0;
20 for (int i = 0; i < n; i++) {
21 s.bar[i] = i;
22 s.sum += s.bar[i];
23 }
[d980649]24 $assert(sum == s.sum);
[48bfab9]25 if(fp != $proc_null) $wait(fp);
[0d850b0]26}
27
28void main() {
[48bfab9]29 $proc fp = $spawn f(3);
30
31 $wait(fp);
[0d850b0]32}
Note: See TracBrowser for help on using the repository browser.