aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-17 00:57:33 -0800
committerMichael Forney <mforney@mforney.org>2019-02-17 00:57:33 -0800
commit863fec184fdb150f4f8758cc68eb6a51f9a38dfe (patch)
tree63f78075067fcded66226eff2968663feb83ec73 /tests
parent7d746860bda62c2f382bc0ac82d4d6c8cdf6c7b2 (diff)
downloadcproc-863fec184fdb150f4f8758cc68eb6a51f9a38dfe.tar.xz
Improve old-style function declaration support
Implement typecompatible for types created with non-prototype function declarations. Require a function definition with parameter declaration list after a declaration with a non-empty identifier list. Detect function definitions with parameter declaration lists containing types incompatible with the promoted types, and report an error for now.
Diffstat (limited to 'tests')
-rw-r--r--tests/compatible-function-types.c17
-rw-r--r--tests/compatible-function-types.qbe16
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/compatible-function-types.c b/tests/compatible-function-types.c
new file mode 100644
index 0000000..0e63a1c
--- /dev/null
+++ b/tests/compatible-function-types.c
@@ -0,0 +1,17 @@
+void f1();
+void f1(int, void *);
+
+int f2();
+int f2(double);
+
+void f3() {}
+void f3(void);
+
+void f4(int, char *);
+void f4(int, char *);
+
+void f5(x, y) unsigned x; double y; {}
+void f5(unsigned, double);
+
+void f6(const char *, ...);
+void f6(const char[], ...);
diff --git a/tests/compatible-function-types.qbe b/tests/compatible-function-types.qbe
new file mode 100644
index 0000000..27d9b32
--- /dev/null
+++ b/tests/compatible-function-types.qbe
@@ -0,0 +1,16 @@
+export
+function $f3() {
+@start.1
+@body.2
+ ret
+}
+export
+function $f5(w %.1, d %.3) {
+@start.3
+ %.2 =l alloc4 4
+ storew %.1, %.2
+ %.4 =l alloc8 8
+ stored %.3, %.4
+@body.4
+ ret
+}