/* Support for printing C and C++ types for GDB, the GNU debugger.
Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
- 1999, 2000, 2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009
+ Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdb_obstack.h"
}
}
+/* Print a typedef using C syntax. TYPE is the underlying type.
+ NEW_SYMBOL is the symbol naming the type. STREAM is the stream on
+ which to print. */
+
+void
+c_print_typedef (struct type *type, struct symbol *new_symbol,
+ struct ui_file *stream)
+{
+ CHECK_TYPEDEF (type);
+ fprintf_filtered (stream, "typedef ");
+ type_print (type, "", stream, 0);
+ if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0
+ || strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))),
+ SYMBOL_LINKAGE_NAME (new_symbol)) != 0)
+ fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new_symbol));
+ fprintf_filtered (stream, ";\n");
+}
+
/* If TYPE is a derived type, then print out derivation information.
Print only the actual base classes of this type, not the base classes
of the base classes. I.E. for the derivation hierarchy:
case TYPE_CODE_COMPLEX:
case TYPE_CODE_TEMPLATE:
case TYPE_CODE_NAMESPACE:
+ case TYPE_CODE_DECFLOAT:
/* These types need no prefix. They are listed here so that
gcc -Wall will reveal any types that haven't been handled. */
break;
fprintf_filtered (stream, "[");
if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
- && TYPE_ARRAY_UPPER_BOUND_TYPE (type) != BOUND_CANNOT_BE_DETERMINED)
+ && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
fprintf_filtered (stream, "%d",
(TYPE_LENGTH (type)
/ TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
case TYPE_CODE_COMPLEX:
case TYPE_CODE_TEMPLATE:
case TYPE_CODE_NAMESPACE:
+ case TYPE_CODE_DECFLOAT:
/* These types do not need a suffix. They are listed so that
gcc -Wall will report types that may not have been considered. */
break;
{
QUIT;
/* Don't print out virtual function table. */
- /* HP ANSI C++ case */
- if (TYPE_HAS_VTABLE (type)
- && (strncmp (TYPE_FIELD_NAME (type, i), "__vfp", 5) == 0))
- continue;
- /* Other compilers */
if (strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5) == 0
&& is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
continue;
}
print_spaces_filtered (level + 4, stream);
- if (TYPE_FIELD_STATIC (type, i))
- {
- fprintf_filtered (stream, "static ");
- }
+ if (field_is_static (&TYPE_FIELD (type, i)))
+ fprintf_filtered (stream, "static ");
c_print_type (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i),
stream, show - 1, level + 4);
- if (!TYPE_FIELD_STATIC (type, i)
+ if (!field_is_static (&TYPE_FIELD (type, i))
&& TYPE_FIELD_PACKED (type, i))
{
/* It is a bitfield. This code does not attempt
TYPE_LOCALTYPE_FILE (type),
TYPE_LOCALTYPE_LINE (type));
}
- if (TYPE_CODE (type) == TYPE_CODE_TEMPLATE)
- goto go_back;
break;
case TYPE_CODE_ENUM:
fprintf_filtered (stream, ", ");
}
fprintf_filtered (stream, "> class ");
- /* Yuck, factor this out to a subroutine so we can call
- it and return to the point marked with the "goback:" label... - RT */
goto struct_union;
- go_back:
- if (TYPE_NINSTANTIATIONS (type) > 0)
- {
- fprintf_filtered (stream, _("\ntemplate instantiations:\n"));
- for (i = 0; i < TYPE_NINSTANTIATIONS (type); i++)
- {
- fprintf_filtered (stream, " ");
- c_type_print_base (TYPE_INSTANTIATION (type, i), stream, 0, level);
- if (i < TYPE_NINSTANTIATIONS (type) - 1)
- fprintf_filtered (stream, "\n");
- }
- }
- break;
case TYPE_CODE_NAMESPACE:
fputs_filtered ("namespace ", stream);