From ed15cddacd145c74e4600af50f6616ba59ca0d8d Mon Sep 17 00:00:00 2001 From: grischka Date: Thu, 13 Oct 2016 19:21:43 +0200 Subject: tccgen: 32bits: fix PTR +/- long long Previously in order to perform a ll+ll operation tcc was trying to 'lexpand' PTR in gen_opl which did not work well. The case: int printf(const char *, ...); char t[] = "012345678"; int main(void) { char *data = t; unsigned long long r = 4; unsigned a = 5; unsigned long long b = 12; *(unsigned*)(data + r) += a - b; printf("data %s\n", data); return 0; } --- tests/tests2/87_ptr_longlong_arith32.c | 15 +++++++++++++++ tests/tests2/87_ptr_longlong_arith32.expect | 1 + 2 files changed, 16 insertions(+) create mode 100644 tests/tests2/87_ptr_longlong_arith32.c create mode 100644 tests/tests2/87_ptr_longlong_arith32.expect (limited to 'tests') diff --git a/tests/tests2/87_ptr_longlong_arith32.c b/tests/tests2/87_ptr_longlong_arith32.c new file mode 100644 index 0000000..bf07915 --- /dev/null +++ b/tests/tests2/87_ptr_longlong_arith32.c @@ -0,0 +1,15 @@ +int printf(const char *, ...); +char t[] = "012345678"; + +int main(void) +{ + char *data = t; + unsigned long long r = 4; + unsigned a = 5; + unsigned long long b = 12; + + *(unsigned*)(data + r) += a - b; + + printf("data = \"%s\"\n", data); + return 0; +} diff --git a/tests/tests2/87_ptr_longlong_arith32.expect b/tests/tests2/87_ptr_longlong_arith32.expect new file mode 100644 index 0000000..f91e4b4 --- /dev/null +++ b/tests/tests2/87_ptr_longlong_arith32.expect @@ -0,0 +1 @@ +data = "0123-5678" -- cgit v1.3.1