diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-12-23 22:45:56 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-12-23 22:45:56 +0100 |
commit | 550880a31688f1031a21efe7923c86db423cbbf1 (patch) | |
tree | f63dfaf4fe5d40e2c682acc3536d7296af75f10d /gcc/cp/init.c | |
parent | 6b7d53a25933f4aed71d6d5134e971bd995f8973 (diff) | |
download | gcc-550880a31688f1031a21efe7923c86db423cbbf1.zip gcc-550880a31688f1031a21efe7923c86db423cbbf1.tar.gz gcc-550880a31688f1031a21efe7923c86db423cbbf1.tar.bz2 |
c++: Fix up floating point complex handling in build_zero_init_1 [PR98353]
While the gimplifier patch I've just committed fixed an ICE, in some cases
like on the committed testcase cp folding doesn't happen after
build_zero_init_1 because it is called already during gimplification.
For the scalar types, if we want to use convert, the problem with complex floats
is that it returns a COMPLEX_EXPR with FLOAT_EXPR arguments which have
INTEGER_CST 0 as argument. As fold isn't recursive, it doesn't do anything
in that case, we need to first fold those FLOAT_EXPRs to REAL_CST 0.0 and
only afterwards the COMPLEX_EXPR can be folded into COMPLEX_CST with 0.0
arguments.
This patch instead just uses build_zero_cst that creates the zero constant for
any scalar types (and more) directly, instead of going through multiple hops.
2020-12-23 Jakub Jelinek <jakub@redhat.com>
PR c++/98353
* init.c (build_zero_init_1): Use build_zero_cst for SCALAR_TYPE_P
zero initializers.
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3c3e05d..903d17f 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -187,7 +187,7 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, else if (NULLPTR_TYPE_P (type)) init = build_int_cst (type, 0); else if (SCALAR_TYPE_P (type)) - init = fold (convert (type, integer_zero_node)); + init = build_zero_cst (type); else if (RECORD_OR_UNION_CODE_P (TREE_CODE (type))) { tree field; |