2004-04-08 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / c-typeprint.c
index 6c5e815e2af2446df95e357b47812b97bfd9561b..c9a644229bb5defa4ee0eddcf0b03ba206359a44 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing C and C++ types for GDB, the GNU debugger.
    Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
-   1999, 2000, 2001, 2002
+   1999, 2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -38,9 +38,6 @@
 #include "gdb_string.h"
 #include <errno.h>
 
-/* Flag indicating target was compiled by HP compiler */
-extern int hp_som_som_object_present;
-
 static void cp_type_print_method_args (struct type *mtype, char *prefix,
                                       char *varstring, int staticp,
                                       struct ui_file *stream);
@@ -65,7 +62,7 @@ void
 c_print_type (struct type *type, char *varstring, struct ui_file *stream,
              int show, int level)
 {
-  register enum type_code code;
+  enum type_code code;
   int demangled_args;
   int need_post_space;
 
@@ -216,7 +213,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
-      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1, 1);
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 1, 1);
       fprintf_filtered (stream, "*");
       c_type_print_modifier (type, stream, 1, need_post_space);
       break;
@@ -224,7 +221,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_MEMBER:
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
-      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
       fprintf_filtered (stream, " ");
       name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
       if (name)
@@ -237,7 +234,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_METHOD:
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
-      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
       if (passed_a_ptr)
        {
          fprintf_filtered (stream, " ");
@@ -247,23 +244,27 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
       break;
 
     case TYPE_CODE_REF:
-      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 1, 0);
       fprintf_filtered (stream, "&");
       c_type_print_modifier (type, stream, 1, need_post_space);
       break;
 
     case TYPE_CODE_FUNC:
-      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
       break;
 
     case TYPE_CODE_ARRAY:
-      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
       if (passed_a_ptr)
        fprintf_filtered (stream, "(");
       break;
 
+    case TYPE_CODE_TYPEDEF:
+      c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
+      break;
+
     case TYPE_CODE_UNDEF:
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
@@ -279,8 +280,8 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_STRING:
     case TYPE_CODE_BITSTRING:
     case TYPE_CODE_COMPLEX:
-    case TYPE_CODE_TYPEDEF:
     case TYPE_CODE_TEMPLATE:
+    case TYPE_CODE_NAMESPACE:
       /* These types need no prefix.  They are listed here so that
          gcc -Wall will reveal any types that haven't been handled.  */
       break;
@@ -300,7 +301,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
                       int need_pre_space, int need_post_space)
 {
   int did_print_modifier = 0;
-  char *address_space_id;
+  const char *address_space_id;
 
   /* We don't print `const' qualifiers for references --- since all
      operators affect the thing referenced, not the reference itself,
@@ -543,19 +544,22 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
                           / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
       fprintf_filtered (stream, "]");
 
-      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
+                                  0, 0);
       break;
 
     case TYPE_CODE_MEMBER:
       if (passed_a_ptr)
        fprintf_filtered (stream, ")");
-      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
+                                  0, 0);
       break;
 
     case TYPE_CODE_METHOD:
       if (passed_a_ptr)
        fprintf_filtered (stream, ")");
-      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
+      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
+                                  0, 0);
       if (passed_a_ptr)
        {
          c_type_print_args (type, stream);
@@ -564,7 +568,8 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
 
     case TYPE_CODE_PTR:
     case TYPE_CODE_REF:
-      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
+      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
+                                  1, 0);
       break;
 
     case TYPE_CODE_FUNC:
@@ -592,7 +597,12 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
              }
          fprintf_filtered (stream, ")");
        }
-      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
+      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
+                                  passed_a_ptr, 0);
+      break;
+
+    case TYPE_CODE_TYPEDEF:
+      c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
                                   passed_a_ptr, 0);
       break;
 
@@ -611,8 +621,8 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_STRING:
     case TYPE_CODE_BITSTRING:
     case TYPE_CODE_COMPLEX:
-    case TYPE_CODE_TYPEDEF:
     case TYPE_CODE_TEMPLATE:
+    case TYPE_CODE_NAMESPACE:
       /* These types do not need a suffix.  They are listed so that
          gcc -Wall will report types that may not have been considered.  */
       break;
@@ -846,10 +856,11 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
              QUIT;
              /* Don't print out virtual function table.  */
              /* HP ANSI C++ case */
-             if (TYPE_HAS_VTABLE (type) && (STREQN (TYPE_FIELD_NAME (type, i), "__vfp", 5)))
+             if (TYPE_HAS_VTABLE (type)
+                 && (strncmp (TYPE_FIELD_NAME (type, i), "__vfp", 5) == 0))
                continue;
              /* Other compilers */
-             if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
+             if (strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0
                  && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
                continue;
 
@@ -931,7 +942,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
              int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
              char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
              char *name = type_name_no_tag (type);
-             int is_constructor = name && STREQ (method_name, name);
+             int is_constructor = name && strcmp (method_name, name) == 0;
              for (j = 0; j < len2; j++)
                {
                  char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
@@ -1064,7 +1075,7 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
     case TYPE_CODE_ENUM:
       c_type_print_modifier (type, stream, 0, 1);
       /* HP C supports sized enums */
-      if (hp_som_som_object_present)
+      if (deprecated_hp_som_som_object_present)
        switch (TYPE_LENGTH (type))
          {
          case 1:
@@ -1171,6 +1182,11 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
        }
       break;
 
+    case TYPE_CODE_NAMESPACE:
+      fputs_filtered ("namespace ", stream);
+      fputs_filtered (TYPE_TAG_NAME (type), stream);
+      break;
+
     default:
       /* Handle types not explicitly handled by the other cases,
          such as fundamental types.  For these, just print whatever
This page took 0.0286729999999999 seconds and 4 git commands to generate.