testsuite: Fix gdb.gdb/selftest.exp for C++-O2-g-built GDB
[deliverable/binutils-gdb.git] / gdb / c-typeprint.c
index 1af477c571d5321b070d1429923480870ce18629..2564ebcf00e00cd6eac2055523b3664e237f7d0c 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for printing C and C++ types for GDB, the GNU debugger.
-   Copyright (C) 1986-2015 Free Software Foundation, Inc.
+   Copyright (C) 1986-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -371,6 +371,7 @@ c_type_print_varspec_prefix (struct type *type,
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
     case TYPE_CODE_ENUM:
+    case TYPE_CODE_FLAGS:
     case TYPE_CODE_INT:
     case TYPE_CODE_FLT:
     case TYPE_CODE_VOID:
@@ -748,6 +749,7 @@ c_type_print_varspec_suffix (struct type *type,
     case TYPE_CODE_UNDEF:
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
+    case TYPE_CODE_FLAGS:
     case TYPE_CODE_ENUM:
     case TYPE_CODE_INT:
     case TYPE_CODE_FLT:
@@ -1305,27 +1307,27 @@ c_type_print_base (struct type *type, struct ui_file *stream,
              if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0)
                fprintf_filtered (stream, "\n");
 
-               for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
-                 {
-                   struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
-
-                   /* Dereference the typedef declaration itself.  */
-                   gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF);
-                   target = TYPE_TARGET_TYPE (target);
-
-                   print_spaces_filtered (level + 4, stream);
-                   fprintf_filtered (stream, "typedef ");
-
-                   /* We want to print typedefs with substitutions
-                      from the template parameters or globally-known
-                      typedefs but not local typedefs.  */
-                   c_print_type (target,
-                                 TYPE_TYPEDEF_FIELD_NAME (type, i),
-                                 stream, show - 1, level + 4,
-                                 &semi_local_flags);
-                   fprintf_filtered (stream, ";\n");
-                 }
-             }
+             for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++)
+               {
+                 struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i);
+
+                 /* Dereference the typedef declaration itself.  */
+                 gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF);
+                 target = TYPE_TARGET_TYPE (target);
+
+                 print_spaces_filtered (level + 4, stream);
+                 fprintf_filtered (stream, "typedef ");
+
+                 /* We want to print typedefs with substitutions
+                    from the template parameters or globally-known
+                    typedefs but not local typedefs.  */
+                 c_print_type (target,
+                               TYPE_TYPEDEF_FIELD_NAME (type, i),
+                               stream, show - 1, level + 4,
+                               &semi_local_flags);
+                 fprintf_filtered (stream, ";\n");
+               }
+           }
 
            fprintfi_filtered (level, stream, "}");
          }
@@ -1402,6 +1404,55 @@ c_type_print_base (struct type *type, struct ui_file *stream,
        }
       break;
 
+    case TYPE_CODE_FLAGS:
+      {
+       struct type_print_options local_flags = *flags;
+
+       local_flags.local_typedefs = NULL;
+
+       c_type_print_modifier (type, stream, 0, 1);
+       fprintf_filtered (stream, "flag ");
+       print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
+       if (show > 0)
+         {
+           fputs_filtered (" ", stream);
+           fprintf_filtered (stream, "{\n");
+           if (TYPE_NFIELDS (type) == 0)
+             {
+               if (TYPE_STUB (type))
+                 fprintfi_filtered (level + 4, stream,
+                                    _("<incomplete type>\n"));
+               else
+                 fprintfi_filtered (level + 4, stream,
+                                    _("<no data fields>\n"));
+             }
+           len = TYPE_NFIELDS (type);
+           for (i = 0; i < len; i++)
+             {
+               QUIT;
+               print_spaces_filtered (level + 4, stream);
+               /* We pass "show" here and not "show - 1" to get enum types
+                  printed.  There's no other way to see them.  */
+               c_print_type (TYPE_FIELD_TYPE (type, i),
+                             TYPE_FIELD_NAME (type, i),
+                             stream, show, level + 4,
+                             &local_flags);
+               fprintf_filtered (stream, " @%s",
+                                 plongest (TYPE_FIELD_BITPOS (type, i)));
+               if (TYPE_FIELD_BITSIZE (type, i) > 1)
+                 {
+                   fprintf_filtered (stream, "-%s",
+                                     plongest (TYPE_FIELD_BITPOS (type, i)
+                                               + TYPE_FIELD_BITSIZE (type, i)
+                                               - 1));
+                 }
+               fprintf_filtered (stream, ";\n");
+             }
+           fprintfi_filtered (level, stream, "}");
+         }
+      }
+      break;
+
     case TYPE_CODE_VOID:
       fprintf_filtered (stream, "void");
       break;
This page took 0.027613 seconds and 4 git commands to generate.