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:
parent
b6a760e554
commit
e236537ab2
|
@ -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();
|
||||||
|
|
4
parse.c
4
parse.c
|
@ -635,7 +635,9 @@ enum ParseResult ParseStatement(struct ParseState *Parser, int CheckTrailingSemi
|
||||||
|
|
||||||
ParseBlock(Parser, TRUE, OldMode != RunModeSkip);
|
ParseBlock(Parser, TRUE, OldMode != RunModeSkip);
|
||||||
|
|
||||||
Parser->Mode = OldMode;
|
if (Parser->Mode != RunModeReturn)
|
||||||
|
Parser->Mode = OldMode;
|
||||||
|
|
||||||
Parser->SearchLabel = OldSearchLabel;
|
Parser->SearchLabel = OldSearchLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void fred(int x)
|
void fred(int x)
|
||||||
{
|
{
|
||||||
switch (x)
|
switch (x)
|
||||||
{
|
{
|
||||||
case 1: printf("1\n"); return;
|
case 1: printf("1\n"); return;
|
||||||
case 2: printf("2\n"); break;
|
case 2: printf("2\n"); break;
|
||||||
case 3: printf("3\n"); return;
|
case 3: printf("3\n"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("out\n");
|
printf("out\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
fred(1);
|
fred(1);
|
||||||
fred(2);
|
fred(2);
|
||||||
fred(3);
|
fred(3);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
tests/47_switch_return.expect
Normal file
4
tests/47_switch_return.expect
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
1
|
||||||
|
2
|
||||||
|
out
|
||||||
|
3
|
|
@ -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: $*...
|
||||||
|
|
Loading…
Reference in a new issue