removed hack for return statement
This commit is contained in:
parent
d35dedf041
commit
5395347582
2 changed files with 14 additions and 9 deletions
|
|
@ -2038,6 +2038,10 @@ proc parseStandaloneClass(p: var TParser, isStruct: bool): PNode =
|
||||||
result = declaration(p)
|
result = declaration(p)
|
||||||
p.currentClass = oldClass
|
p.currentClass = oldClass
|
||||||
|
|
||||||
|
proc unwrap(a: PNode): PNode =
|
||||||
|
if a.kind == nkPar:
|
||||||
|
return a.sons[0]
|
||||||
|
return a
|
||||||
|
|
||||||
include cpp
|
include cpp
|
||||||
|
|
||||||
|
|
@ -2072,16 +2076,10 @@ proc statement(p: var TParser): PNode =
|
||||||
of "return":
|
of "return":
|
||||||
result = newNodeP(nkReturnStmt, p)
|
result = newNodeP(nkReturnStmt, p)
|
||||||
getTok(p)
|
getTok(p)
|
||||||
# special case for ``return (expr)`` because I hate the redundant
|
if p.tok.xkind == pxSemicolon:
|
||||||
# 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:
|
|
||||||
addSon(result, ast.emptyNode)
|
addSon(result, ast.emptyNode)
|
||||||
|
else:
|
||||||
|
addSon(result, unwrap(expression(p)))
|
||||||
eat(p, pxSemicolon)
|
eat(p, pxSemicolon)
|
||||||
of "enum": result = enumSpecifier(p)
|
of "enum": result = enumSpecifier(p)
|
||||||
of "typedef": result = parseTypeDef(p)
|
of "typedef": result = parseTypeDef(p)
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,16 @@
|
||||||
|
|
||||||
int rand(void);
|
int rand(void);
|
||||||
|
|
||||||
|
int id2(void) {
|
||||||
|
return (int *)1;
|
||||||
|
}
|
||||||
|
|
||||||
int id(void (*f)(void)) {
|
int id(void (*f)(void)) {
|
||||||
f();
|
f();
|
||||||
((void (*)(int))f)(10);
|
((void (*)(int))f)(10);
|
||||||
|
return 10;
|
||||||
|
return (20+1);
|
||||||
|
return (int *)id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue