From 7d746860bda62c2f382bc0ac82d4d6c8cdf6c7b2 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 16 Feb 2019 20:47:45 -0800 Subject: Extend char/short types before comparing Thanks to Andrew Chambers for reporting the issue. --- tests/cast-bool-char.c | 3 +++ tests/cast-bool-char.qbe | 10 ++++++++++ tests/compare-char.c | 3 +++ tests/compare-char.qbe | 11 +++++++++++ 4 files changed, 27 insertions(+) create mode 100644 tests/cast-bool-char.c create mode 100644 tests/cast-bool-char.qbe create mode 100644 tests/compare-char.c create mode 100644 tests/compare-char.qbe (limited to 'tests') diff --git a/tests/cast-bool-char.c b/tests/cast-bool-char.c new file mode 100644 index 0000000..d05f575 --- /dev/null +++ b/tests/cast-bool-char.c @@ -0,0 +1,3 @@ +int main(void) { + return (_Bool)(unsigned char)256; +} diff --git a/tests/cast-bool-char.qbe b/tests/cast-bool-char.qbe new file mode 100644 index 0000000..81d4eba --- /dev/null +++ b/tests/cast-bool-char.qbe @@ -0,0 +1,10 @@ +export +function w $main() { +@start.1 +@body.2 + %.1 =w copy 256 + %.2 =w extub %.1 + %.3 =w cnew %.2, 0 + %.4 =w extub %.3 + ret %.4 +} diff --git a/tests/compare-char.c b/tests/compare-char.c new file mode 100644 index 0000000..5219647 --- /dev/null +++ b/tests/compare-char.c @@ -0,0 +1,3 @@ +int main(void) { + return (unsigned char)0 < (unsigned char)256; +} diff --git a/tests/compare-char.qbe b/tests/compare-char.qbe new file mode 100644 index 0000000..a0a1c03 --- /dev/null +++ b/tests/compare-char.qbe @@ -0,0 +1,11 @@ +export +function w $main() { +@start.1 +@body.2 + %.1 =w copy 0 + %.2 =w copy 256 + %.3 =w extub %.1 + %.4 =w extub %.2 + %.5 =w cultw %.3, %.4 + ret %.5 +} -- cgit v1.2.3