aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-02-09 09:31:55 +0100
committerJakub Jelinek <jakub@redhat.com>2023-02-09 09:31:55 +0100
commitb1ed0c9671b99c6b06cbb8c61be14cdec0998de8 (patch)
tree7a46c33514034237e89ba76bafdc03a36e961840 /gcc/cp
parent4b19ff1b5ef684c2d9ccd4fb275aeef0a4b0b980 (diff)
downloadgcc-b1ed0c9671b99c6b06cbb8c61be14cdec0998de8.zip
gcc-b1ed0c9671b99c6b06cbb8c61be14cdec0998de8.tar.gz
gcc-b1ed0c9671b99c6b06cbb8c61be14cdec0998de8.tar.bz2
c++: Mangle EXCESS_PRECISION_EXPR <REAL_CST> as fold_convert REAL_CST [PR108698]
For standard excess precision, like the C FE we parse floating point constants as EXCESS_PRECISION_EXPR of promoted REAL_CST rather than the nominal REAL_CST, and as the following testcase shows the constants might need mangling. The following patch mangles those as fold_convert of the REAL_CST to EXCESS_PRECISION_EXPR type, i.e. how they were mangled before. I'm not really sure EXCESS_PRECISION_EXPR can appear elsewhere in expressions that would need mangling, tried various testcases but haven't managed to come up with one. If that is possible, we'd keep ICEing on it without/with this patch, and the big question is how to mangle those; they could be mangled as casts from the promoted type back to nominal, but then in the mangled expressions one could see the effects of excess precision. Until we have a reproducer, that is just theoretical though. 2023-02-09 Jakub Jelinek <jakub@redhat.com> PR c++/108698 * mangle.cc (write_expression, write_template_arg): Handle EXCESS_PRECISION_EXPR with REAL_CST operand as write_template_arg_literal on fold_convert of the REAL_CST to EXCESS_PRECISION_EXPR type. * g++.dg/cpp0x/pr108698.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/mangle.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index f2cda3b..f2761d2 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -3107,6 +3107,10 @@ write_expression (tree expr)
else if (TREE_CODE_CLASS (code) == tcc_constant
|| code == CONST_DECL)
write_template_arg_literal (expr);
+ else if (code == EXCESS_PRECISION_EXPR
+ && TREE_CODE (TREE_OPERAND (expr, 0)) == REAL_CST)
+ write_template_arg_literal (fold_convert (TREE_TYPE (expr),
+ TREE_OPERAND (expr, 0)));
else if (code == PARM_DECL && DECL_ARTIFICIAL (expr))
{
gcc_assert (id_equal (DECL_NAME (expr), "this"));
@@ -3815,6 +3819,10 @@ write_template_arg (tree node)
|| code == CONST_DECL
|| null_member_pointer_value_p (node))
write_template_arg_literal (node);
+ else if (code == EXCESS_PRECISION_EXPR
+ && TREE_CODE (TREE_OPERAND (node, 0)) == REAL_CST)
+ write_template_arg_literal (fold_convert (TREE_TYPE (node),
+ TREE_OPERAND (node, 0)));
else if (DECL_P (node))
{
write_char ('L');