cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit a813137236b2c51de81dff3a869887f1b91cebee
parent b530731adbf3a8ebdde77bd61fca3593e9f00896
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 15 May 2019 23:48:29 -0700

Remove incorrect type equality check in usual arithmetic conversions

Integer types still undergo integer promotions even if they are the
same type.

Diffstat:
Atest/common-real-unsigned-char.c | 3+++
Atest/common-real-unsigned-char.qbe | 12++++++++++++
Mtest/compare-char.qbe | 8++++----
Mtype.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 @@ -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 @@ -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 @@ -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 } diff --git a/type.c b/type.c @@ -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)