diff --git a/picoc.c b/picoc.c index ae73591..d8f0ed2 100644 --- a/picoc.c +++ b/picoc.c @@ -38,8 +38,11 @@ void Cleanup() void CallMain(int argc, char **argv) { /* check if the program wants arguments */ - struct Value *FuncValue; + struct Value *FuncValue = NULL; + if (!VariableDefined(TableStrRegister("main"))) + return; + VariableGet(NULL, TableStrRegister("main"), &FuncValue); if (FuncValue->Typ->Base != TypeFunction) ProgramFail(NULL, "main is not a function - can't call it"); diff --git a/tests/25_quicksort.c b/tests/25_quicksort.c index 922fd41..724d9c5 100644 --- a/tests/25_quicksort.c +++ b/tests/25_quicksort.c @@ -77,5 +77,4 @@ void main() printf("\n"); } -main(); diff --git a/tests/30_hanoi.c b/tests/30_hanoi.c index 02ff6d2..42ce561 100644 --- a/tests/30_hanoi.c +++ b/tests/30_hanoi.c @@ -121,6 +121,3 @@ main() Hanoi(N,A,B,C); return 0; } - - -main(); diff --git a/tests/Makefile b/tests/Makefile index 2834b8c..1adf379 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -44,7 +44,7 @@ TESTS= 00_assignment.test \ then \ ../picoc $*.c - arg1 arg2 arg3 arg4 2>&1 >$*.output; \ else \ - ../picoc -m $*.c 2>&1 >$*.output; \ + ../picoc $*.c 2>&1 >$*.output; \ fi @if [ "x`diff -qbu $*.expect $*.output`" != "x" ]; \ then \