]> git.ipfire.org Git - thirdparty/gcc.git/commit
c, c++: Fix up excess precision handling of scalar_to_vector conversion [PR107358]
authorJakub Jelinek <jakub@redhat.com>
Mon, 24 Oct 2022 15:53:16 +0000 (17:53 +0200)
committerJakub Jelinek <jakub@redhat.com>
Mon, 24 Oct 2022 15:54:17 +0000 (17:54 +0200)
commit65e3274e363cb2c6bfe6b5e648916eb7696f7e2f
tree6b9b50d26c3954f7255a51f41bca267b82e4adb4
parent131d18e928a3ea1ab2d3bf61aa92d68a8a254609
c, c++: Fix up excess precision handling of scalar_to_vector conversion [PR107358]

As mentioned earlier in the C++ excess precision support mail, the following
testcase is broken with excess precision both in C and C++ (though just in C++
it was triggered in real-world code).
scalar_to_vector is called in both FEs after the excess precision promotions
(or stripping of EXCESS_PRECISION_EXPR), so we can then get invalid
diagnostics that say float vector + float involves truncation (on ia32
from long double to float).

The following patch fixes that by calling scalar_to_vector on the operands
before the excess precision promotions, let scalar_to_vector just do the
diagnostics (it does e.g. fold_for_warn so it will fold
EXCESS_PRECISION_EXPR around REAL_CST to constants etc.) but will then
do the actual conversions using the excess precision promoted operands
(so say if we have vector double + (float + float) we don't actually do
vector double + (float) ((long double) float + (long double) float)
but
vector double + (double) ((long double) float + (long double) float)

2022-10-24  Jakub Jelinek  <jakub@redhat.com>

PR c++/107358
gcc/c/
* c-typeck.cc (build_binary_op): Pass operands before excess precision
promotions to scalar_to_vector call.
gcc/cp/
* typeck.cc (cp_build_binary_op): Pass operands before excess precision
promotions to scalar_to_vector call.
gcc/testsuite/
* c-c++-common/pr107358.c: New test.
* g++.dg/cpp1y/pr68180.C: Remove -fexcess-precision=fast from
dg-options.
gcc/c/c-typeck.cc
gcc/cp/typeck.cc
gcc/testsuite/c-c++-common/pr107358.c [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/pr68180.C