Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / args.c
1 /** Tests argument passing to functions.
2     Assumes that up to the first two arguments can be passed in registers.
3
4     type1: char, int, long
5     type2: char, int, long
6     type3: char, int, long
7  */
8 #include <testfwk.h>
9
10 static {type1}
11 returnFirstArg({type1} arg1, {type2} arg2, {type3} arg3)
12 {
13     UNUSED(arg2);
14     UNUSED(arg3);
15     return arg1;
16 }
17
18 static {type2}
19 returnSecondArg({type1} arg1, {type2} arg2, {type3} arg3)
20 {
21     UNUSED(arg1);
22     UNUSED(arg3);
23     return arg2;
24 }
25
26 static {type3}
27 returnThirdArg({type1} arg1, {type2} arg2, {type3} arg3)
28 {
29     UNUSED(arg1);
30     UNUSED(arg2);
31     return arg3;
32 }
33
34 static void
35 testArgs(void)
36 {
37     ASSERT(returnFirstArg(123, 45, 67) == 123);
38     ASSERT(returnFirstArg(-123, 45, 67) == -123);
39
40     ASSERT(returnSecondArg(1, -23, 64) == -23);
41     ASSERT(returnSecondArg(1, 8, 64) == 8);
42
43     ASSERT(returnThirdArg(-33, -34, -35) == -35);
44     ASSERT(returnThirdArg(-33, -34, 35) == 35);
45
46 }