Hi,

the compiler can synthesize DWARF functions to describe the location and size
of components in discriminated record types with variant part in Ada, but in
peculiar cases the compiler drops expressions on the floor, for example in
the divide case:

     case ROUND_DIV_EXPR:
     case TRUNC_DIV_EXPR:
     case EXACT_DIV_EXPR:
      if (TYPE_UNSIGNED (TREE_TYPE (loc)))
        return 0;
       op = DW_OP_div;
       goto do_binop;

Now sizetype and bitsizetype are unsigned types, which means that any divide
expression in them is dropped.  But the sign bit is expected to be never set
for sizetype or bitsizetype quantities so that's unnecessarily cautious.

Tested on x86-64/Linux, both GCC and GDB, OK for the mainline?


2021-04-26  Eric Botcazou  <ebotca...@adacore.com>

        * dwarf2out.c (loc_list_from_tree_1) <EXACT_DIV_EXPR>: Do not bail out
        for sizetype and bitsizetype.

-- 
Eric Botcazou
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index c36fd5a7f6a..c6584aa03c3 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18994,7 +18999,10 @@ loc_list_from_tree_1 (tree loc, int want_address,
     case ROUND_DIV_EXPR:
     case TRUNC_DIV_EXPR:
     case EXACT_DIV_EXPR:
-      if (TYPE_UNSIGNED (TREE_TYPE (loc)))
+      /* The sign bit is expected to be never set for sizetypes.  */
+      if (TYPE_UNSIGNED (TREE_TYPE (loc))
+	  && TREE_TYPE (loc) != sizetype
+	  && TREE_TYPE (loc) != bitsizetype)
 	return 0;
       op = DW_OP_div;
       goto do_binop;

Reply via email to