Append $PLT_CFLAGS to CC for NOCROSSREFS tests
[binutils-gdb.git] / gdb / c-valprint.c
index a22a9d3d1d167d908d8f17156af28004c30ea68b..2009e953a95eaad9914a36495c508c6bb9cbc514 100644 (file)
@@ -422,6 +422,60 @@ c_val_print_union (struct type *type, const gdb_byte *valaddr,
     }
 }
 
+/* c_val_print helper for TYPE_CODE_INT.  */
+
+static void
+c_val_print_int (struct type *type, struct type *unresolved_type,
+                const gdb_byte *valaddr, int embedded_offset,
+                struct ui_file *stream, const struct value *original_value,
+                const struct value_print_options *options)
+{
+  if (options->format || options->output_format)
+    {
+      struct value_print_options opts = *options;
+
+      opts.format = (options->format ? options->format
+                    : options->output_format);
+      val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                 original_value, &opts, 0, stream);
+    }
+  else
+    {
+      val_print_type_code_int (type, valaddr + embedded_offset,
+                              stream);
+      /* C and C++ has no single byte int type, char is used
+        instead.  Since we don't know whether the value is really
+        intended to be used as an integer or a character, print
+        the character equivalent as well.  */
+      if (c_textual_element_type (unresolved_type, options->format))
+       {
+         fputs_filtered (" ", stream);
+         LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset),
+                        unresolved_type, stream);
+       }
+    }
+}
+
+/* c_val_print helper for TYPE_CODE_MEMBERPTR.  */
+
+static void
+c_val_print_memberptr (struct type *type, const gdb_byte *valaddr,
+                      int embedded_offset, CORE_ADDR address,
+                      struct ui_file *stream, int recurse,
+                      const struct value *original_value,
+                      const struct value_print_options *options)
+{
+  if (!options->format)
+    {
+      cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
+    }
+  else
+    {
+      generic_val_print (type, valaddr, embedded_offset, address, stream,
+                        recurse, original_value, options, &c_decorations);
+    }
+}
+
 /* See val_print for a description of the various parameters of this
    function; they are identical.  */
 
@@ -434,7 +488,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
 {
   struct type *unresolved_type = type;
 
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_ARRAY:
@@ -462,39 +516,14 @@ c_val_print (struct type *type, const gdb_byte *valaddr,
       break;
 
     case TYPE_CODE_INT:
-      if (options->format || options->output_format)
-       {
-         struct value_print_options opts = *options;
-
-         opts.format = (options->format ? options->format
-                        : options->output_format);
-         val_print_scalar_formatted (type, valaddr, embedded_offset,
-                                     original_value, &opts, 0, stream);
-       }
-      else
-       {
-         val_print_type_code_int (type, valaddr + embedded_offset,
-                                  stream);
-         /* C and C++ has no single byte int type, char is used
-            instead.  Since we don't know whether the value is really
-            intended to be used as an integer or a character, print
-            the character equivalent as well.  */
-         if (c_textual_element_type (unresolved_type, options->format))
-           {
-             fputs_filtered (" ", stream);
-             LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset),
-                            unresolved_type, stream);
-           }
-       }
+      c_val_print_int (type, unresolved_type, valaddr, embedded_offset, stream,
+                      original_value, options);
       break;
 
     case TYPE_CODE_MEMBERPTR:
-      if (!options->format)
-       {
-         cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
-         break;
-       }
-      /* FALLTHROUGH */
+      c_val_print_memberptr (type, valaddr, embedded_offset, address, stream,
+                            recurse, original_value, options);
+      break;
 
     case TYPE_CODE_REF:
     case TYPE_CODE_ENUM: