aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-02-11 13:52:44 +0100
committerJakub Jelinek <jakub@redhat.com>2022-02-11 13:52:44 +0100
commit84993d94e13ad2ab3aee151bb5a5e767cf75d51e (patch)
tree63393b62cb2ff535bad7f56e8184b17c380a59b3 /gcc/cp/constexpr.cc
parentfb76c0ad35f96505ecd9213849ebc3df6163a0f7 (diff)
downloadgcc-84993d94e13ad2ab3aee151bb5a5e767cf75d51e.zip
gcc-84993d94e13ad2ab3aee151bb5a5e767cf75d51e.tar.gz
gcc-84993d94e13ad2ab3aee151bb5a5e767cf75d51e.tar.bz2
c++: Fix up constant expression __builtin_convertvector folding [PR104472]
The following testcase ICEs, because due to the -frounding-math fold_const_call fails, which is it returns NULL, and returning NULL from cxx_eval* is wrong, all the callers rely on them to either return folded value or original with *non_constant_p = true. The following patch does that, and additionally falls through into the default case where there is diagnostics for the !ctx->quiet case too. 2022-02-11 Jakub Jelinek <jakub@redhat.com> PR c++/104472 * constexpr.cc (cxx_eval_internal_function) <case IFN_VEC_CONVERT>: Only return fold_const_call result if it is non-NULL. Otherwise fall through into the default: case to return t, set *non_constant_p and emit diagnostics if needed. * g++.dg/cpp0x/constexpr-104472.C: New test.
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 9b8e0ec..87f3a7b 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -1840,13 +1840,10 @@ cxx_eval_internal_function (const constexpr_ctx *ctx, tree t,
false, non_constant_p,
overflow_p);
if (TREE_CODE (arg) == VECTOR_CST)
- return fold_const_call (CFN_VEC_CONVERT, TREE_TYPE (t), arg);
- else
- {
- *non_constant_p = true;
- return t;
- }
+ if (tree r = fold_const_call (CFN_VEC_CONVERT, TREE_TYPE (t), arg))
+ return r;
}
+ /* FALLTHRU */
default:
if (!ctx->quiet)