diff options
author | Jason Merrill <jason@redhat.com> | 2009-11-05 08:11:42 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-11-05 08:11:42 -0500 |
commit | 5ab8b6b550c078fed66f1939d310802963772edb (patch) | |
tree | 6c86c36cfecb8833e95ede308a00666d2b0d8612 /gcc/varasm.c | |
parent | 30a20e97315d434e2b68134fc794fb500245085a (diff) | |
download | gcc-5ab8b6b550c078fed66f1939d310802963772edb.zip gcc-5ab8b6b550c078fed66f1939d310802963772edb.tar.gz gcc-5ab8b6b550c078fed66f1939d310802963772edb.tar.bz2 |
re PR c++/36912 (ICE with "-frounding-math -g")
PR c++/36912
* varasm.c (initializer_constant_valid_p): A PLUS_EXPR
or MINUS_EXPR of REAL_TYPE is not a valid constant initializer.
(output_constant): Avoid crash after error.
From-SVN: r153936
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index b6ff4ae..c9953d1 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4322,6 +4322,10 @@ initializer_constant_valid_p (tree value, tree endtype) case POINTER_PLUS_EXPR: case PLUS_EXPR: + /* Any valid floating-point constants will have been folded by now; + with -frounding-math we hit this with addition of two constants. */ + if (TREE_CODE (endtype) == REAL_TYPE) + return NULL_TREE; if (! INTEGRAL_TYPE_P (endtype) || TYPE_PRECISION (endtype) >= int_or_pointer_precision (TREE_TYPE (value))) @@ -4345,6 +4349,8 @@ initializer_constant_valid_p (tree value, tree endtype) break; case MINUS_EXPR: + if (TREE_CODE (endtype) == REAL_TYPE) + return NULL_TREE; if (! INTEGRAL_TYPE_P (endtype) || TYPE_PRECISION (endtype) >= int_or_pointer_precision (TREE_TYPE (value))) @@ -4560,8 +4566,8 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align) case REAL_TYPE: if (TREE_CODE (exp) != REAL_CST) error ("initializer for floating value is not a floating constant"); - - assemble_real (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)), align); + else + assemble_real (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)), align); break; case COMPLEX_TYPE: |