diff options
author | Michael Forney <mforney@mforney.org> | 2019-05-15 23:48:29 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-05-16 00:33:57 -0700 |
commit | a813137236b2c51de81dff3a869887f1b91cebee (patch) | |
tree | e3f7fa1a8e8da76fd7a538ad7123eee5b468b52a | |
parent | b530731adbf3a8ebdde77bd61fca3593e9f00896 (diff) |
Remove incorrect type equality check in usual arithmetic conversions
Integer types still undergo integer promotions even if they are the
same type.
-rw-r--r-- | test/common-real-unsigned-char.c | 3 | ||||
-rw-r--r-- | test/common-real-unsigned-char.qbe | 12 | ||||
-rw-r--r-- | test/compare-char.qbe | 8 | ||||
-rw-r--r-- | type.c | 2 |
4 files changed, 19 insertions, 6 deletions
diff --git a/test/common-real-unsigned-char.c b/test/common-real-unsigned-char.c new file mode 100644 index 0000000..c4a7625 --- /dev/null +++ b/test/common-real-unsigned-char.c @@ -0,0 +1,3 @@ +int main(void) { + return ((unsigned char)1 - (unsigned char)2) > 0; +} diff --git a/test/common-real-unsigned-char.qbe b/test/common-real-unsigned-char.qbe new file mode 100644 index 0000000..4835e5a --- /dev/null +++ b/test/common-real-unsigned-char.qbe @@ -0,0 +1,12 @@ +export +function w $main() { +@start.1 +@body.2 + %.1 =w copy 1 + %.2 =w extub %.1 + %.3 =w copy 2 + %.4 =w extub %.3 + %.5 =w sub %.2, %.4 + %.6 =w csgtw %.5, 0 + ret %.6 +} diff --git a/test/compare-char.qbe b/test/compare-char.qbe index a0a1c03..33ccd4c 100644 --- a/test/compare-char.qbe +++ b/test/compare-char.qbe @@ -3,9 +3,9 @@ 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 + %.2 =w extub %.1 + %.3 =w copy 256 + %.4 =w extub %.3 + %.5 =w csltw %.2, %.4 ret %.5 } @@ -204,8 +204,6 @@ typecommonreal(struct type *t1, unsigned w1, struct type *t2, unsigned w2) struct type *tmp; assert(t1->prop & PROPREAL && t2->prop & PROPREAL); - if (t1 == t2) - return t1; if (t1 == &typeldouble || t2 == &typeldouble) return &typeldouble; if (t1 == &typedouble || t2 == &typedouble) |