translate_c: prevent a while under an if from stealing the else
This commit is contained in:
committed by
Andrew Kelley
parent
135cb529de
commit
2d7b55aa0a
@@ -1767,4 +1767,21 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {
|
||||
\\ return 0;
|
||||
\\}
|
||||
, "");
|
||||
|
||||
cases.add("Ensure while loop under an if doesn't steal the else. Issue #9953",
|
||||
\\#include <stdio.h>
|
||||
\\void doWork(int id) { }
|
||||
\\int reallyDelete(int id) { printf("deleted %d\n", id); return 1; }
|
||||
\\int process(int id, int n, int delete) {
|
||||
\\ if(!delete)
|
||||
\\ while(n-- > 0) doWork(id);
|
||||
\\ else
|
||||
\\ return reallyDelete(id);
|
||||
\\ return 0;
|
||||
\\}
|
||||
\\int main(void) {
|
||||
\\ process(99, 3, 0);
|
||||
\\ return 0;
|
||||
\\}
|
||||
, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user