diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-03-31 08:32:46 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-03-31 08:32:46 +0200 |
commit | a7d551541989a53c964d5cc54359069bf4cf919a (patch) | |
tree | fea535e8d66f9e488a837e68fe8734100a548f95 /gcc/varasm.c | |
parent | 005f12bf67e60ada0757470be80fe69799a83ebc (diff) | |
download | gcc-a7d551541989a53c964d5cc54359069bf4cf919a.zip gcc-a7d551541989a53c964d5cc54359069bf4cf919a.tar.gz gcc-a7d551541989a53c964d5cc54359069bf4cf919a.tar.bz2 |
re PR middle-end/80163 (ICE on hopefully valid code)
PR middle-end/80163
* varasm.c (initializer_constant_valid_p_1): Disallow sign-extending
conversions to integer types wider than word and pointer.
* gcc.dg/pr80163.c: New test.
From-SVN: r246607
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 11a8ac4..05e48a5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4472,8 +4472,15 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) return initializer_constant_valid_p_1 (src, endtype, cache); /* Allow conversions between other integer types only if - explicit value. */ - if (INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type)) + explicit value. Don't allow sign-extension to a type larger + than word and pointer, there aren't relocations that would + allow to sign extend it to a wider type. */ + if (INTEGRAL_TYPE_P (dest_type) + && INTEGRAL_TYPE_P (src_type) + && (TYPE_UNSIGNED (src_type) + || TYPE_PRECISION (dest_type) <= TYPE_PRECISION (src_type) + || TYPE_PRECISION (dest_type) <= BITS_PER_WORD + || TYPE_PRECISION (dest_type) <= POINTER_SIZE)) { tree inner = initializer_constant_valid_p_1 (src, endtype, cache); if (inner == null_pointer_node) |