Commit a7d55154 by Jakub Jelinek Committed by Jakub Jelinek

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
parent 005f12bf
2017-03-31 Jakub Jelinek <jakub@redhat.com> 2017-03-31 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80163
* varasm.c (initializer_constant_valid_p_1): Disallow sign-extending
conversions to integer types wider than word and pointer.
PR debug/80025 PR debug/80025
* cselib.h (rtx_equal_for_cselib_1): Add depth argument. * cselib.h (rtx_equal_for_cselib_1): Add depth argument.
(rtx_equal_for_cselib_p): Pass 0 to it. (rtx_equal_for_cselib_p): Pass 0 to it.
......
2017-03-31 Jakub Jelinek <jakub@redhat.com> 2017-03-31 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80163
* gcc.dg/pr80163.c: New test.
PR debug/80025 PR debug/80025
* gcc.dg/torture/pr80025.c: New test. * gcc.dg/torture/pr80025.c: New test.
......
/* PR middle-end/80163 */
/* { dg-do compile { target int128 } } */
/* { dg-options "-O0" } */
void bar (void);
__int128_t *
foo (void)
{
a:
bar ();
b:;
static __int128_t d = (long) &&a - (long) &&b; /* { dg-error "initializer element is not computable at load time" } */
return &d;
}
__int128_t *
baz (void)
{
static __int128_t d = (long) (3 * 4);
return &d;
}
...@@ -4472,8 +4472,15 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache) ...@@ -4472,8 +4472,15 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache)
return initializer_constant_valid_p_1 (src, endtype, cache); return initializer_constant_valid_p_1 (src, endtype, cache);
/* Allow conversions between other integer types only if /* Allow conversions between other integer types only if
explicit value. */ explicit value. Don't allow sign-extension to a type larger
if (INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type)) 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); tree inner = initializer_constant_valid_p_1 (src, endtype, cache);
if (inner == null_pointer_node) if (inner == null_pointer_node)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment