Implement Ada operator overloading
[deliverable/binutils-gdb.git] / gdb / typeprint.c
index f947faf315f6566d74f1b0bb53b49f3ef7ba11e2..1af1d173a6186f6bad2f68ec24ff4f93c3fdbed6 100644 (file)
@@ -1,6 +1,6 @@
 /* Language independent support for printing types for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2020 Free Software Foundation, Inc.
+   Copyright (C) 1986-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -490,10 +490,12 @@ whatis_exp (const char *exp, int show)
         "whatis" prints the type of the expression without stripping
         any typedef level.  "ptype" always strips all levels of
         typedefs.  */
-      if (show == -1 && expr->elts[0].opcode == OP_TYPE)
+      val = evaluate_type (expr.get ());
+      type = value_type (val);
+
+      if (show == -1 && expr->first_opcode () == OP_TYPE)
        {
          /* The user expression names a type directly.  */
-         type = expr->elts[1].type;
 
          /* If this is a typedef, then find its immediate target.
             Use check_typedef to resolve stubs, but ignore its result
@@ -506,14 +508,6 @@ whatis_exp (const char *exp, int show)
             value to fetch the dynamic type from.  */
          val = NULL;
        }
-      else
-       {
-         /* The user expression names a type indirectly by naming an
-            object or expression of that type.  Find that
-            indirectly-named type.  */
-         val = evaluate_type (expr.get ());
-         type = value_type (val);
-       }
     }
   else
     {
@@ -637,6 +631,10 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
       print_type_scalar (TYPE_TARGET_TYPE (type), val, stream);
       return;
 
+    case TYPE_CODE_FIXED_POINT:
+      print_type_fixed_point (type, stream);
+      break;
+
     case TYPE_CODE_UNDEF:
     case TYPE_CODE_PTR:
     case TYPE_CODE_ARRAY:
@@ -667,11 +665,10 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
 void
 print_type_fixed_point (struct type *type, struct ui_file *stream)
 {
-  gdb::unique_xmalloc_ptr<char> small_img
-    = fixed_point_scaling_factor (type).str ();
+  std::string small_img = type->fixed_point_scaling_factor ().str ();
 
   fprintf_filtered (stream, "%s-byte fixed point (small = %s)",
-                   pulongest (TYPE_LENGTH (type)), small_img.get ());
+                   pulongest (TYPE_LENGTH (type)), small_img.c_str ());
 }
 
 /* Dump details of a type specified either directly or indirectly.
@@ -681,28 +678,14 @@ print_type_fixed_point (struct type *type, struct ui_file *stream)
 void
 maintenance_print_type (const char *type_name, int from_tty)
 {
-  struct value *val;
-  struct type *type;
-
   if (type_name != NULL)
     {
       expression_up expr = parse_expression (type_name);
-      if (expr->elts[0].opcode == OP_TYPE)
-       {
-         /* The user expression names a type directly, just use that type.  */
-         type = expr->elts[1].type;
-       }
-      else
-       {
-         /* The user expression may name a type indirectly by naming an
-            object of that type.  Find that indirectly named type.  */
-         val = evaluate_type (expr.get ());
-         type = value_type (val);
-       }
-      if (type != NULL)
-       {
-         recursive_dump_type (type, 0);
-       }
+      struct value *val = evaluate_type (expr.get ());
+      struct type *type = value_type (val);
+
+      if (type != nullptr)
+       recursive_dump_type (type, 0);
     }
 }
 \f
This page took 0.024873 seconds and 4 git commands to generate.