public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-10131] c-family: Fix up shorten_compare for decimal vs. non-decimal float comparison [PR104510] Date: Wed, 11 May 2022 06:25:02 +0000 (GMT) [thread overview] Message-ID: <20220511062502.866A73856255@sourceware.org> (raw) https://gcc.gnu.org/g:b65f562b8f203948ebe1c09d9710184b0a2052bb commit r9-10131-gb65f562b8f203948ebe1c09d9710184b0a2052bb Author: Jakub Jelinek <jakub@redhat.com> Date: Wed Feb 16 09:25:55 2022 +0100 c-family: Fix up shorten_compare for decimal vs. non-decimal float comparison [PR104510] The comment in shorten_compare says: /* If either arg is decimal float and the other is float, fail. */ but the callers of shorten_compare don't expect anything like failure as a possibility from the function, callers require that the function promotes the operands to the same type, whether the original selected *restype_ptr one or some shortened. So, if we choose not to shorten, we should still promote to the original *restype_ptr. 2022-02-16 Jakub Jelinek <jakub@redhat.com> PR c/104510 * c-common.c (shorten_compare): Convert original arguments to the original *restype_ptr when mixing binary and decimal float. * gcc.dg/dfp/pr104510.c: New test. (cherry picked from commit 6e74122f0de6748b3fd0ed9183090cd7c61fb53e) Diff: --- gcc/c-family/c-common.c | 6 +++++- gcc/testsuite/gcc.dg/dfp/pr104510.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 910407374d2..880292f13e2 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2993,7 +2993,11 @@ shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr, else if (real1 && real2 && (DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop0))) || DECIMAL_FLOAT_MODE_P (TYPE_MODE (TREE_TYPE (primop1))))) - return NULL_TREE; + { + type = *restype_ptr; + primop0 = op0; + primop1 = op1; + } else if (real1 && real2 && (TYPE_PRECISION (TREE_TYPE (primop0)) diff --git a/gcc/testsuite/gcc.dg/dfp/pr104510.c b/gcc/testsuite/gcc.dg/dfp/pr104510.c new file mode 100644 index 00000000000..85f4e9707de --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/pr104510.c @@ -0,0 +1,12 @@ +/* PR c/104510 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +float f; +_Decimal64 d; + +int +foo (void) +{ + return d > (_Decimal32) (_Decimal64) f; +}
reply other threads:[~2022-05-11 6:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220511062502.866A73856255@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).