PR tui/16138 is about failure to initialize curses resulting in GDB
[deliverable/binutils-gdb.git] / gdb / c-typeprint.c
index c6f8bb23c6b3a17ec069e6d28acd3d8ddbd2cfc3..374c90e3be6a1f3bab3396b8c23a89006181b5db 100644 (file)
@@ -1,6 +1,5 @@
 /* Support for printing C and C++ types for GDB, the GNU debugger.
-   Copyright (C) 1986, 1988-1989, 1991-1996, 1998-2003, 2006-2012 Free
-   Software Foundation, Inc.
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -32,8 +31,6 @@
 #include "typeprint.h"
 #include "cp-abi.h"
 #include "jv-lang.h"
-#include "gdb_string.h"
-#include <errno.h>
 #include "cp-support.h"
 
 static void c_type_print_varspec_prefix (struct type *,
@@ -270,6 +267,9 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
 
       if (TYPE_VOLATILE (domain))
        fprintf_filtered (stream, " volatile");
+
+      if (TYPE_RESTRICT (domain))
+       fprintf_filtered (stream, " restrict");
     }
 }
 
@@ -423,6 +423,14 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
       did_print_modifier = 1;
     }
 
+  if (TYPE_RESTRICT (type))
+    {
+      if (did_print_modifier || need_pre_space)
+       fprintf_filtered (stream, " ");
+      fprintf_filtered (stream, "restrict");
+      did_print_modifier = 1;
+    }
+
   address_space_id = address_space_int_to_name (get_type_arch (type),
                                                TYPE_INSTANCE_FLAGS (type));
   if (address_space_id)
@@ -452,13 +460,10 @@ c_type_print_args (struct type *type, struct ui_file *stream,
                   int linkage_name, enum language language,
                   const struct type_print_options *flags)
 {
-  int i, len;
-  struct field *args;
+  int i;
   int printed_any = 0;
 
   fprintf_filtered (stream, "(");
-  args = TYPE_FIELDS (type);
-  len = TYPE_NFIELDS (type);
 
   for (i = 0; i < TYPE_NFIELDS (type); i++)
     {
@@ -682,7 +687,11 @@ c_type_print_varspec_suffix (struct type *type,
 
        fprintf_filtered (stream, (is_vector ?
                                   " __attribute__ ((vector_size(" : "["));
-       if (get_array_bounds (type, &low_bound, &high_bound))
+       /* Bounds are not yet resolved, print a bounds placeholder instead.  */
+       if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
+           || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
+         fprintf_filtered (stream, "variable length");
+       else if (get_array_bounds (type, &low_bound, &high_bound))
          fprintf_filtered (stream, "%s", 
                            plongest (high_bound - low_bound + 1));
        fprintf_filtered (stream, (is_vector ? ")))" : "]"));
@@ -1143,7 +1152,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                  struct cleanup *inner_cleanup;
                  const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
                  int is_full_physname_constructor =
-                   is_constructor_name (physname) 
+                   TYPE_FN_FIELD_CONSTRUCTOR (f, j)
+                   || is_constructor_name (physname)
                    || is_destructor_name (physname)
                    || method_name[0] == '~';
 
@@ -1219,8 +1229,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                    mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
 
                  demangled_name =
-                   cplus_demangle (mangled_name,
-                                   DMGL_ANSI | DMGL_PARAMS);
+                   gdb_demangle (mangled_name,
+                                 DMGL_ANSI | DMGL_PARAMS);
                  if (demangled_name == NULL)
                    {
                      /* In some cases (for instance with the HP
@@ -1287,7 +1297,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
                  {
                    struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
-                   struct typedef_hash_table *table2;
 
                    /* Dereference the typedef declaration itself.  */
                    gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF);
@@ -1308,12 +1317,6 @@ c_type_print_base (struct type *type, struct ui_file *stream,
              }
 
            fprintfi_filtered (level, stream, "}");
-
-           if (TYPE_LOCALTYPE_PTR (type) && show >= 0)
-             fprintfi_filtered (level,
-                                stream, _(" (Local at %s:%d)\n"),
-                                TYPE_LOCALTYPE_FILE (type),
-                                TYPE_LOCALTYPE_LINE (type));
          }
 
        do_cleanups (local_cleanups);
@@ -1323,6 +1326,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
     case TYPE_CODE_ENUM:
       c_type_print_modifier (type, stream, 0, 1);
       fprintf_filtered (stream, "enum ");
+      if (TYPE_DECLARED_CLASS (type))
+       fprintf_filtered (stream, "class ");
       /* Print the tag name if it exists.
          The aCC compiler emits a spurious 
          "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
@@ -1348,6 +1353,23 @@ c_type_print_base (struct type *type, struct ui_file *stream,
        {
          LONGEST lastval = 0;
 
+         /* We can't handle this case perfectly, as DWARF does not
+            tell us whether or not the underlying type was specified
+            in the source (and other debug formats don't provide this
+            at all).  We choose to print the underlying type, if it
+            has a name, when in C++ on the theory that it's better to
+            print too much than too little; but conversely not to
+            print something egregiously outside the current
+            language's syntax.  */
+         if (current_language->la_language == language_cplus
+             && TYPE_TARGET_TYPE (type) != NULL)
+           {
+             struct type *underlying = check_typedef (TYPE_TARGET_TYPE (type));
+
+             if (TYPE_NAME (underlying) != NULL)
+               fprintf_filtered (stream, ": %s ", TYPE_NAME (underlying));
+           }
+
          fprintf_filtered (stream, "{");
          len = TYPE_NFIELDS (type);
          for (i = 0; i < len; i++)
This page took 0.02818 seconds and 4 git commands to generate.