Functions returning void fixed
git-svn-id: http://picoc.googlecode.com/svn/trunk@176 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
1b312544d9
commit
b9990d2c39
1
TODO
1
TODO
|
@ -10,6 +10,7 @@ Bugs:
|
|||
}
|
||||
return (i * fact(i - 1));
|
||||
}
|
||||
* something wrong with interactive mode after error handling - not clearing token buffer correctly?
|
||||
|
||||
Implement:
|
||||
* operator precedence
|
||||
|
|
6
parse.c
6
parse.c
|
@ -100,9 +100,6 @@ void ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
|
|||
do
|
||||
{
|
||||
TypeParseIdentPart(Parser, BasicType, &Typ, &Identifier);
|
||||
if (Token == TokenVoidType && Identifier != StrEmpty)
|
||||
ProgramFail(Parser, "can't define a void variable");
|
||||
|
||||
if ((Token != TokenVoidType && Token != TokenStructType && Token != TokenUnionType) && Identifier == StrEmpty)
|
||||
ProgramFail(Parser, "identifier expected");
|
||||
|
||||
|
@ -113,6 +110,9 @@ void ParseDeclaration(struct ParseState *Parser, enum LexToken Token)
|
|||
ParseFunctionDefinition(Parser, Typ, Identifier, FALSE);
|
||||
else
|
||||
{
|
||||
if (Token == TokenVoidType && Identifier != StrEmpty)
|
||||
ProgramFail(Parser, "can't define a void variable");
|
||||
|
||||
if (LexGetToken(Parser, NULL, FALSE) != TokenAssign)
|
||||
VariableDefine(Parser, Identifier, VariableAllocValueFromType(Parser, Typ, TRUE, NULL));
|
||||
else
|
||||
|
|
|
@ -6,3 +6,10 @@ int myfunc(int x)
|
|||
printint(myfunc(3));
|
||||
printint(myfunc(4));
|
||||
|
||||
void vfunc(int a)
|
||||
{
|
||||
printf("a=%d\n", a);
|
||||
}
|
||||
|
||||
vfunc(1234);
|
||||
|
||||
|
|
Loading…
Reference in a new issue