PR22348, conflicting global vars in crx and cr16
[deliverable/binutils-gdb.git] / gdb / p-typeprint.c
index 239869171f5a56124a0ae6031874144c44287f93..33b4992c335d583b369d9167b9eb074851e8185f 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for printing Pascal types for GDB, the GNU debugger.
-   Copyright (C) 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 2000-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -55,7 +55,7 @@ pascal_print_type (struct type *type, const char *varstring,
   code = TYPE_CODE (type);
 
   if (show > 0)
-    CHECK_TYPEDEF (type);
+    type = check_typedef (type);
 
   if ((code == TYPE_CODE_FUNC
        || code == TYPE_CODE_METHOD))
@@ -96,7 +96,7 @@ void
 pascal_print_typedef (struct type *type, struct symbol *new_symbol,
                      struct ui_file *stream)
 {
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
   fprintf_filtered (stream, "type ");
   fprintf_filtered (stream, "%s = ", SYMBOL_PRINT_NAME (new_symbol));
   type_print (type, "", stream, 0);
@@ -154,8 +154,8 @@ void
 pascal_type_print_method_args (const char *physname, const char *methodname,
                               struct ui_file *stream)
 {
-  int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
-  int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
+  int is_constructor = (startswith (physname, "__ct__"));
+  int is_destructor = (startswith (physname, "__dt__"));
 
   if (is_constructor || is_destructor)
     {
@@ -227,7 +227,8 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_METHOD:
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
-      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+      if (TYPE_TARGET_TYPE (type) != NULL
+         && TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
        {
          fprintf_filtered (stream, "function  ");
        }
@@ -239,7 +240,7 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
       if (passed_a_ptr)
        {
          fprintf_filtered (stream, " ");
-         pascal_type_print_base (TYPE_DOMAIN_TYPE (type),
+         pascal_type_print_base (TYPE_SELF_TYPE (type),
                                  stream, 0, passed_a_ptr, flags);
          fprintf_filtered (stream, "::");
        }
@@ -255,7 +256,8 @@ pascal_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
 
-      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+      if (TYPE_TARGET_TYPE (type) != NULL
+         && TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
        {
          fprintf_filtered (stream, "function  ");
        }
@@ -334,6 +336,33 @@ pascal_print_func_args (struct type *type, struct ui_file *stream,
     }
 }
 
+/* Helper for pascal_type_print_varspec_suffix to print the suffix of
+   a function or method.  */
+
+static void
+pascal_type_print_func_varspec_suffix  (struct type *type, struct ui_file *stream,
+                                       int show, int passed_a_ptr,
+                                       int demangled_args,
+                                       const struct type_print_options *flags)
+{
+  if (TYPE_TARGET_TYPE (type) == NULL
+      || TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+    {
+      fprintf_filtered (stream, " : ");
+      pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
+                                       stream, 0, 0, flags);
+
+      if (TYPE_TARGET_TYPE (type) == NULL)
+       type_print_unknown_return_type (stream);
+      else
+       pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
+                               flags);
+
+      pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+                                       passed_a_ptr, 0, flags);
+    }
+}
+
 /* Print any array sizes, function arguments or close parentheses
    needed after the variable name (to describe its type).
    Args work like pascal_type_print_varspec_prefix.  */
@@ -365,16 +394,8 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
       pascal_type_print_method_args ("",
                                     "",
                                     stream);
-      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
-       {
-         fprintf_filtered (stream, " : ");
-         pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
-                                           stream, 0, 0, flags);
-         pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
-                                 flags);
-         pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
-                                           passed_a_ptr, 0, flags);
-       }
+      pascal_type_print_func_varspec_suffix (type, stream, show,
+                                            passed_a_ptr, 0, flags);
       break;
 
     case TYPE_CODE_PTR:
@@ -388,16 +409,8 @@ pascal_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
        fprintf_filtered (stream, ")");
       if (!demangled_args)
        pascal_print_func_args (type, stream, flags);
-      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
-       {
-         fprintf_filtered (stream, " : ");
-         pascal_type_print_varspec_prefix (TYPE_TARGET_TYPE (type),
-                                           stream, 0, 0, flags);
-         pascal_type_print_base (TYPE_TARGET_TYPE (type), stream, show, 0,
-                                 flags);
-         pascal_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
-                                           passed_a_ptr, 0, flags);
-       }
+      pascal_type_print_func_varspec_suffix (type, stream, show,
+                                            passed_a_ptr, 0, flags);
       break;
 
     case TYPE_CODE_UNDEF:
@@ -479,7 +492,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
       return;
     }
 
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
 
   switch (TYPE_CODE (type))
     {
@@ -567,7 +580,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
            {
              QUIT;
              /* Don't print out virtual function table.  */
-             if ((strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0)
+             if ((startswith (TYPE_FIELD_NAME (type, i), "_vptr"))
                  && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
                continue;
 
@@ -643,8 +656,8 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
                {
                  const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
 
-                 int is_constructor = (strncmp (physname, "__ct__", 6) == 0);
-                 int is_destructor = (strncmp (physname, "__dt__", 6) == 0);
+                 int is_constructor = (startswith (physname, "__ct__"));
+                 int is_destructor = (startswith (physname, "__dt__"));
 
                  QUIT;
                  if (TYPE_FN_FIELD_PROTECTED (f, j))
This page took 0.030878 seconds and 4 git commands to generate.