removed hack for return statement

This commit is contained in:
Vincent Burns
2014-01-14 12:05:14 -05:00
parent d35dedf041
commit 5395347582
2 changed files with 14 additions and 9 deletions

View File

@@ -2038,6 +2038,10 @@ proc parseStandaloneClass(p: var TParser, isStruct: bool): PNode =
result = declaration(p)
p.currentClass = oldClass
proc unwrap(a: PNode): PNode =
if a.kind == nkPar:
return a.sons[0]
return a
include cpp
@@ -2072,16 +2076,10 @@ proc statement(p: var TParser): PNode =
of "return":
result = newNodeP(nkReturnStmt, p)
getTok(p)
# special case for ``return (expr)`` because I hate the redundant
# parenthesis ;-)
if p.tok.xkind == pxParLe:
getTok(p, result)
addSon(result, expression(p))
eat(p, pxParRi, result)
elif p.tok.xkind != pxSemicolon:
addSon(result, expression(p))
else:
if p.tok.xkind == pxSemicolon:
addSon(result, ast.emptyNode)
else:
addSon(result, unwrap(expression(p)))
eat(p, pxSemicolon)
of "enum": result = enumSpecifier(p)
of "typedef": result = parseTypeDef(p)

View File

@@ -3,9 +3,16 @@
int rand(void);
int id2(void) {
return (int *)1;
}
int id(void (*f)(void)) {
f();
((void (*)(int))f)(10);
return 10;
return (20+1);
return (int *)id;
}
int main() {