aboutsummaryrefslogtreecommitdiff
path: root/tests/iii
diff options
context:
space:
mode:
Diffstat (limited to 'tests/iii')
-rw-r--r--tests/iii/extern-struct-rejected/case.json12
-rw-r--r--tests/iii/extern-struct-rejected/notes.md5
-rw-r--r--tests/iii/extern-struct-rejected/program.cps14
3 files changed, 31 insertions, 0 deletions
diff --git a/tests/iii/extern-struct-rejected/case.json b/tests/iii/extern-struct-rejected/case.json
new file mode 100644
index 0000000..6a4483f
--- /dev/null
+++ b/tests/iii/extern-struct-rejected/case.json
@@ -0,0 +1,12 @@
+{
+ "errors": [
+ {
+ "reason": "EXTERN\\ parameter\\ 1\\ of\\ puts\\ uses\\ record\\ Person,\\ which\\ is\\ not\\ a\\ C\\ struct:\\ field\\ Name\\ of\\ Person\\ has\\ type\\ STRING",
+ "line": 12
+ },
+ {
+ "reason": "EXTERN\\ parameter\\ 1\\ of\\ abs\\ cannot\\ be\\ record\\ Point\\ by\\ value;\\ use\\ a\\ pointer\\ type\\ to\\ it",
+ "line": 13
+ }
+ ]
+}
diff --git a/tests/iii/extern-struct-rejected/notes.md b/tests/iii/extern-struct-rejected/notes.md
new file mode 100644
index 0000000..f33ef66
--- /dev/null
+++ b/tests/iii/extern-struct-rejected/notes.md
@@ -0,0 +1,5 @@
+# extern-struct-rejected
+
+Compiler extension: an EXTERN signature accepts a record only as a C struct (every field a C type, a C struct or a pointer type to one) and, for now, only through a pointer type. Person has a STRING field, so a pointer to it is rejected and the field is named. Point is a C struct, but passing it by value is not supported yet.
+
+Require exit 1 and each cause on its EXTERN line.
diff --git a/tests/iii/extern-struct-rejected/program.cps b/tests/iii/extern-struct-rejected/program.cps
new file mode 100644
index 0000000..e7f38d1
--- /dev/null
+++ b/tests/iii/extern-struct-rejected/program.cps
@@ -0,0 +1,14 @@
+// Records cross the EXTERN boundary only as C structs through a pointer type.
+INCLUDE_OBJ "__libc"
+TYPE Person
+ DECLARE Name : STRING
+ DECLARE Age : C_INT
+ENDTYPE
+TYPE PPerson = ^Person
+TYPE Point
+ DECLARE X : C_INT
+ DECLARE Y : C_INT
+ENDTYPE
+EXTERN "C" EXTERN_PROCEDURE puts(PPerson)
+EXTERN "C" EXTERN_FUNCTION abs(Point) RETURNS C_INT
+OUTPUT 1