From 9f964b728151066dd37dd80269ed23ea4b4cdeab Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 18 Feb 2019 12:34:25 -0800 Subject: Fix compatible check for basic types This check was only supposed to return true for enum types and their corresponding integer type. However, it had the side effect of making 'int' compatible with 'unsigned'. To fix this, introduce a new basic type kind for enums with the same rank as 'int', that is only compatible with itself and the 'int' type with the matching sign. Thanks to Andrew Chambers for the bug report. --- tests/common-real-int-sign.c | 4 ++++ tests/common-real-int-sign.qbe | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/common-real-int-sign.c create mode 100644 tests/common-real-int-sign.qbe (limited to 'tests') diff --git a/tests/common-real-int-sign.c b/tests/common-real-int-sign.c new file mode 100644 index 0000000..d67c301 --- /dev/null +++ b/tests/common-real-int-sign.c @@ -0,0 +1,4 @@ +int main(void) { + unsigned x = -1; + return 0 > x; +} diff --git a/tests/common-real-int-sign.qbe b/tests/common-real-int-sign.qbe new file mode 100644 index 0000000..589c72e --- /dev/null +++ b/tests/common-real-int-sign.qbe @@ -0,0 +1,14 @@ +export +function w $main() { +@start.1 + %.1 =l alloc4 4 +@body.2 + %.2 =l add %.1, 0 + %.3 =w sub 0, 1 + %.4 =w copy %.3 + storew %.4, %.2 + %.5 =w copy 0 + %.6 =w loaduw %.1 + %.7 =w cugtw %.5, %.6 + ret %.7 +} -- cgit v1.2.3