]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/ada-valprint.c
Fix Ada overloading with 'null'
[thirdparty/binutils-gdb.git] / gdb / ada-valprint.c
index 61c903bbed544bc951875118da59891d5e3e156c..d516a4d134e8e3e8853581d4c6e174c799f84e28 100644 (file)
@@ -719,6 +719,14 @@ ada_value_print_ptr (struct value *val,
                     struct ui_file *stream, int recurse,
                     const struct value_print_options *options)
 {
+  if (!options->format
+      && TYPE_TARGET_TYPE (value_type (val))->code () == TYPE_CODE_INT
+      && TYPE_LENGTH (TYPE_TARGET_TYPE (value_type (val))) == 0)
+    {
+      fputs_filtered ("null", stream);
+      return;
+    }
+
   common_val_print (val, stream, recurse, options, language_def (language_c));
 
   struct type *type = ada_check_typedef (value_type (val));
@@ -1096,8 +1104,11 @@ ada_value_print (struct value *val0, struct ui_file *stream,
   struct type *type = ada_check_typedef (value_type (val));
   struct value_print_options opts;
 
-  /* If it is a pointer, indicate what it points to.  */
-  if (type->code () == TYPE_CODE_PTR)
+  /* If it is a pointer, indicate what it points to; but not for
+     "void *" pointers.  */
+  if (type->code () == TYPE_CODE_PTR
+      && !(TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_INT
+          && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == 0))
     {
       /* Hack:  don't print (char *) for char strings.  Their
         type is indicated by the quoted string anyway.  */