Implement arrays.
Added check to see that pointer types are compatible when passing function
arguments.
diff --git a/libacc/tests/data/array.c b/libacc/tests/data/array.c
new file mode 100644
index 0000000..3af5e31
--- /dev/null
+++ b/libacc/tests/data/array.c
@@ -0,0 +1,77 @@
+// Array allocation tests
+
+void testLocalInt()
+{
+ int a[3];
+ a[0] = 1;
+ a[1] = 2;
+ a[2] = a[0] + a[1];
+ printf("localInt: %d\n", a[2]);
+}
+
+char a[3];
+double d[3];
+
+void testGlobalChar()
+{
+ a[0] = 1;
+ a[1] = 2;
+ a[2] = a[0] + a[1];
+ printf("globalChar: %d\n", a[2]);
+}
+
+void testGlobalDouble()
+{
+ d[0] = 1;
+ d[1] = 2;
+ d[2] = d[0] + d[1];
+ printf("globalDouble: %g\n", d[2]);
+}
+
+void testLocalDouble()
+{
+ double d[3];
+ float m[12];
+ m[0] = 1.0f;
+ m[1] = 2.0f;
+ d[0] = 1.0;
+ d[1] = 2.0;
+ d[2] = d[0] + d[1];
+ m[2] = m[0] + m[1];
+ printf("localDouble: %g %g\n", d[2], m[2]);
+}
+
+void vectorAdd(int* a, int* b, float* c, int len) {
+ int i;
+ for(i = 0; i < len; i++) {
+ c[i] = a[i] + b[i];
+ }
+}
+
+void testArgs() {
+ int a[3], b[3];
+ float c[3];
+ int i;
+ int len = 3;
+ for(i = 0; i < len; i++) {
+ a[i] = i;
+ b[i] = i;
+ c[i] = 0;
+ }
+ vectorAdd(a,b,c, len);
+ printf("testArgs:");
+ for(i = 0; i < len; i++) {
+ printf(" %g", c[i]);
+ }
+ printf("\n");
+}
+
+int main()
+{
+ testLocalInt();
+ testLocalDouble();
+ testGlobalChar();
+ testGlobalDouble();
+ testArgs();
+ return 0;
+}
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
index a3114ad..4ad2e13 100644
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -387,6 +387,16 @@
result: -2
""","""""")
+ def testArray(self):
+ self.compileCheck(["-R", "data/array.c"], """Executing compiled code:
+localInt: 3
+localDouble: 3 3
+globalChar: 3
+globalDouble: 3
+testArgs: 0 2 4
+result: 0
+""","""""")
+
if __name__ == '__main__':
if not outputCanRun():
print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable."