+2020-09-29  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/die.h (struct die_info) <addr_base, ranges_base>: Check
+       the attribute's form.
+
 2020-09-29  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c.
 
 #ifndef GDB_DWARF2_DIE_H
 #define GDB_DWARF2_DIE_H
 
+#include "complaints.h"
+
 /* This data structure holds a complete die structure.  */
 struct die_info
 {
   {
     for (unsigned i = 0; i < num_attrs; ++i)
       if (attrs[i].name == DW_AT_addr_base
-         || attrs[i].name == DW_AT_GNU_addr_base)
+          || attrs[i].name == DW_AT_GNU_addr_base)
        {
-         /* If both exist, just use the first one.  */
-         return DW_UNSND (&attrs[i]);
+         if (attrs[i].form_is_unsigned ())
+           {
+             /* If both exist, just use the first one.  */
+             return attrs[i].as_unsigned ();
+           }
+         complaint (_("address base attribute (offset %s) as wrong form"),
+                    sect_offset_str (sect_off));
        }
     return gdb::optional<ULONGEST> ();
   }
       if (attrs[i].name == DW_AT_rnglists_base
          || attrs[i].name == DW_AT_GNU_ranges_base)
        {
-         /* If both exist, just use the first one.  */
-         return DW_UNSND (&attrs[i]);
+         if (attrs[i].form_is_unsigned ())
+           {
+             /* If both exist, just use the first one.  */
+             return attrs[i].as_unsigned ();
+           }
+         complaint (_("ranges base attribute (offset %s) as wrong form"),
+                    sect_offset_str (sect_off));
        }
     return 0;
   }