Re: [PATCH] Don't ICE on && in dwarf2out (PR debug/89704)

2019-03-14 Thread Jason Merrill

On 3/14/19 7:01 PM, Jakub Jelinek wrote:

Hi!

On the following testcase, we have tree initializers that satisfy
initializer_constant_valid_p and do:
   rtl = rtl_for_decl_init (init, type);
   if (rtl)
 return add_const_value_attribute (die, rtl);
add_const_value_attribute has a list of rtl codes it expects in the
initializers (and wants to handle only the simplest cases anyway), but
doesn't cover what can appear in these initializers, MINUS for the pointer
subtraction and the *_EXTEND for the casts.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-03-14  Jakub Jelinek  

PR debug/89704
* dwarf2out.c (add_const_value_attribute): Return false for MINUS,
SIGN_EXTEND and ZERO_EXTEND.


OK.

Jason


[PATCH] Don't ICE on && in dwarf2out (PR debug/89704)

2019-03-14 Thread Jakub Jelinek
Hi!

On the following testcase, we have tree initializers that satisfy
initializer_constant_valid_p and do:
  rtl = rtl_for_decl_init (init, type);
  if (rtl)
return add_const_value_attribute (die, rtl);
add_const_value_attribute has a list of rtl codes it expects in the
initializers (and wants to handle only the simplest cases anyway), but
doesn't cover what can appear in these initializers, MINUS for the pointer
subtraction and the *_EXTEND for the casts.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2019-03-14  Jakub Jelinek  

PR debug/89704
* dwarf2out.c (add_const_value_attribute): Return false for MINUS,
SIGN_EXTEND and ZERO_EXTEND.

* gcc.dg/debug/pr89704.c: New test.

--- gcc/dwarf2out.c.jj  2019-03-13 21:21:58.0 +0100
+++ gcc/dwarf2out.c 2019-03-14 15:31:00.180137759 +0100
@@ -19670,6 +19670,9 @@ add_const_value_attribute (dw_die_ref di
 
 case HIGH:
 case CONST_FIXED:
+case MINUS:
+case SIGN_EXTEND:
+case ZERO_EXTEND:
   return false;
 
 case MEM:
--- gcc/testsuite/gcc.dg/debug/pr89704.c.jj 2019-03-14 15:36:39.239657822 
+0100
+++ gcc/testsuite/gcc.dg/debug/pr89704.c2019-03-14 15:36:34.559733459 
+0100
@@ -0,0 +1,14 @@
+/* PR debug/89704 */
+/* { dg-do compile } */
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+int
+foo (void)
+{
+  lab1:;
+  lab2:;
+  static int i = (intptr_t) & - (intptr_t) &
+  static int j = (intptr_t) & - (intptr_t) &
+  return i;
+}

Jakub