translate-c: Support compound assignment of pointer and signed int

This handles `ptr += idx` and `ptr -= idx` when `idx` is a
signed integer expression.
This commit is contained in:
Evan Haas
2021-03-05 09:54:59 -08:00
committed by Veikka Tuominen
parent 874c63f89c
commit 6d69a29d75
2 changed files with 35 additions and 9 deletions

View File

@@ -1154,6 +1154,16 @@ pub fn addCases(cases: *tests.RunTranslatedCContext) void {
\\ y = x - idx;
\\ if (y != x + 1 || y != &array[6]) abort();
\\
\\ idx = 1;
\\ x += idx;
\\ if (x != &array[6]) abort();
\\ x -= idx;
\\ if (x != &array[5]) abort();
\\ y = (x += idx);
\\ if (y != x || y != &array[6]) abort();
\\ y = (x -= idx);
\\ if (y != x || y != &array[5]) abort();
\\
\\ return 0;
\\}
, "");