summaryrefslogtreecommitdiff
path: root/support/regression/tests/args.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /support/regression/tests/args.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'support/regression/tests/args.c')
-rw-r--r--support/regression/tests/args.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/support/regression/tests/args.c b/support/regression/tests/args.c
new file mode 100644
index 0000000..ce331c1
--- /dev/null
+++ b/support/regression/tests/args.c
@@ -0,0 +1,50 @@
+/** Tests argument passing to functions.
+ Assumes that up to the first two arguments can be passed in registers.
+
+ type1: char, int, long
+ type2: char, int, long
+ type3: char, int, long
+ */
+#include <testfwk.h>
+
+#define TYPE3_{type3}
+
+static {type1}
+returnFirstArg({type1} arg1, {type2} arg2, {type3} arg3)
+{
+ UNUSED(arg2);
+ UNUSED(arg3);
+ return arg1;
+}
+
+static {type2}
+returnSecondArg({type1} arg1, {type2} arg2, {type3} arg3)
+{
+ UNUSED(arg1);
+ UNUSED(arg3);
+ return arg2;
+}
+
+static {type3}
+returnThirdArg({type1} arg1, {type2} arg2, {type3} arg3)
+{
+ UNUSED(arg1);
+ UNUSED(arg2);
+ return arg3;
+}
+
+static void
+testArgs(void)
+{
+#if !(defined(__SDCC_pdk14) && defined(TYPE3_long)) // Not enough RAM
+ ASSERT(returnFirstArg(123, 45, 67) == ({type1})123);
+ ASSERT(returnFirstArg(-123, 45, 67) == ({type1})-123);
+
+ ASSERT(returnSecondArg(1, -23, 64) == ({type2})-23);
+ ASSERT(returnSecondArg(1, 8, 64) == ({type2})8);
+
+ ASSERT(returnThirdArg(-33, -34, -35) == ({type3})-35);
+ ASSERT(returnThirdArg(-33, -34, 35) == ({type3})35);
+#endif
+}
+