Fixed problem with returns inside switch() statements not working correctly outside the switch block.

Issue #116


git-svn-id: http://picoc.googlecode.com/svn/trunk@506 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2011-02-11 04:49:44 +00:00
parent b6a760e554
commit e236537ab2
5 changed files with 33 additions and 25 deletions

View file

@ -1234,7 +1234,7 @@ void ExpressionParseMacroCall(struct ParseState *Parser, struct ExpressionStack
#ifndef NO_FP #ifndef NO_FP
ExpressionStackPushValueByType(Parser, StackTop, &FPType); /* largest return type there is */ ExpressionStackPushValueByType(Parser, StackTop, &FPType); /* largest return type there is */
#else #else
ExpressionStackPushValueByType(Parser, StackTop, VoidPtrType); /* largest return type there is */ ExpressionStackPushValueByType(Parser, StackTop, IntType); /* largest return type there is */
#endif #endif
ReturnValue = (*StackTop)->Val; ReturnValue = (*StackTop)->Val;
HeapPushStackFrame(); HeapPushStackFrame();

View file

@ -635,7 +635,9 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
ParseBlock(Parser, TRUE, OldMode != RunModeSkip); ParseBlock(Parser, TRUE, OldMode != RunModeSkip);
if (Parser->Mode != RunModeReturn)
Parser->Mode = OldMode; Parser->Mode = OldMode;
Parser->SearchLabel = OldSearchLabel; Parser->SearchLabel = OldSearchLabel;
} }

View file

@ -20,3 +20,4 @@ int main()
return 0; return 0;
} }

View file

@ -0,0 +1,4 @@
1
2
out
3

View file

@ -40,7 +40,8 @@ TESTS= 00_assignment.test \
41_hashif.test \ 41_hashif.test \
43_void_param.test \ 43_void_param.test \
44_scoped_declarations.test \ 44_scoped_declarations.test \
45_empty_for.test 45_empty_for.test \
47_switch_return.test
%.test: %.expect %.c %.test: %.expect %.c
@echo Test: $*... @echo Test: $*...