Skip to content

Commit 1f10e5f

Browse files
committed
Fixed varargs variables & struct members
1 parent 36e50d5 commit 1f10e5f

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

Changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Version 7.4.4
22
- Added some missing libc.a files (thanks to Ada)
3-
- Improved module constant overrides
3+
- Fixed parameter checking for varargs function variables
4+
- Slightly improved module constant overrides; significant issues remain
45

56
Version 7.4.3
67
- Remove some unused debug strings when debugging is not enabled

Test/Expect/cexec05.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
hello, world
2+
number: 1
3+
tuple: 2, here

Test/cexec05.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
#include <propeller.h>
3+
#undef printf /* in case it was defined to __builtin_printf */
4+
5+
typedef struct sx1268_handle_s {
6+
void (*debug_print)(const char *const fmt, ...);
7+
} handle;
8+
9+
handle foo;
10+
11+
void myexit(int n)
12+
{
13+
putchar(0xff);
14+
putchar(0x0);
15+
putchar(n);
16+
waitcnt(getcnt() + 40000000);
17+
#ifdef __OUTPUT_BYTECODE__
18+
_cogstop(_cogid());
19+
#else
20+
__asm {
21+
cogid n
22+
cogstop n
23+
}
24+
#endif
25+
}
26+
27+
void main() {
28+
foo.debug_print = (void *)printf;
29+
foo.debug_print("hello, world\n");
30+
foo.debug_print("number: %d\n", 1);
31+
foo.debug_print("tuple: %d, %s\n", 2, "here");
32+
myexit(0);
33+
}

functions.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,15 +2025,19 @@ ExpandArguments(AST *sendptr, AST *args)
20252025
* count number of (actual) parameters passed to a function
20262026
* (e.g. 64 bit parameters count as two parameters)
20272027
*/
2028-
int
2029-
CountParameters(AST *list)
2028+
static int
2029+
CountParameters(AST *list, int *is_varargs)
20302030
{
20312031
AST *param;
20322032
int n = 0;
20332033
while (list) {
20342034
param = list->left;
20352035
list = list->right;
2036-
n += NumExprItemsOnStack(param);
2036+
if (param && param->kind == AST_VARARGS) {
2037+
*is_varargs = 1;
2038+
} else {
2039+
n += NumExprItemsOnStack(param);
2040+
}
20372041
}
20382042
return n;
20392043
}
@@ -2103,7 +2107,7 @@ CheckFunctionCalls(AST *ast)
21032107
}
21042108
}
21052109
if (ftype) {
2106-
expectArgs = CountParameters(ftype->right);
2110+
expectArgs = CountParameters(ftype->right, &is_varargs);
21072111
} else {
21082112
expectArgs = 0;
21092113
is_varargs = 1;

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define VERSION_MAJOR 7
88
#define VERSION_MINOR 4
99
#define VERSION_REV 4
10-
#define BETA "-beta"
10+
//#define BETA "-beta"
1111

1212
#define VERSIONSTR version_string
1313

0 commit comments

Comments
 (0)