gdb_printf (stream, "}");
 }
 
+/* A wrapper for cp_print_value_fields that tries to apply a
+   pretty-printer first.  */
+
+static void
+cp_print_value_fields_pp (struct value *val,
+                         struct ui_file *stream,
+                         int recurse,
+                         const struct value_print_options *options,
+                         struct type **dont_print_vb,
+                         int dont_print_statmem)
+{
+  int result = 0;
+
+  /* Attempt to run an extension language pretty-printer if
+     possible.  */
+  if (!options->raw)
+    result
+      = apply_ext_lang_val_pretty_printer (val, stream,
+                                          recurse, options,
+                                          current_language);
+
+  if (!result)
+    cp_print_value_fields (val, stream, recurse, options, dont_print_vb,
+                          dont_print_statmem);
+}
+
 /* Special val_print routine to avoid printing multiple copies of
    virtual baseclasses.  */
 
        val_print_invalid_address (stream);
       else
        {
-         int result = 0;
-
          if (!val_print_check_max_depth (stream, recurse, options,
                                          current_language))
            {
              struct value *baseclass_val = val->primitive_field (0,
                                                                  i, type);
 
-             /* Attempt to run an extension language pretty-printer on the
-                baseclass if possible.  */
-             if (!options->raw)
-               result
-                 = apply_ext_lang_val_pretty_printer (baseclass_val, stream,
-                                                      recurse, options,
-                                                      current_language);
-
-             if (!result)
-               cp_print_value_fields (baseclass_val, stream, recurse, options,
-                                      ((struct type **)
-                                       obstack_base (&dont_print_vb_obstack)),
-                                      0);
+             cp_print_value_fields_pp
+               (baseclass_val, stream, recurse, options,
+                (struct type **) obstack_base (&dont_print_vb_obstack),
+                0);
            }
        }
       gdb_puts (", ", stream);
 
       obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
                    sizeof (CORE_ADDR));
-      cp_print_value_fields (val, stream, recurse, options, NULL, 1);
+      cp_print_value_fields_pp (val, stream, recurse, options, nullptr, 1);
       return;
     }