aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-typeprint.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/c-typeprint.c')
-rw-r--r--gdb/c-typeprint.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 97f7aaa..6141950 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1189,13 +1189,13 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed
enum}" tag for unnamed struct/union/enum's, which we don't
want to print. */
- if (TYPE_TAG_NAME (type) != NULL
- && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
+ if (TYPE_NAME (type) != NULL
+ && !startswith (TYPE_NAME (type), "{unnamed"))
{
/* When printing the tag name, we are still effectively
printing in the outer context, hence the use of FLAGS
here. */
- print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream);
+ print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
fputs_filtered (" ", stream);
}
@@ -1204,10 +1204,10 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
{
/* If we just printed a tag name, no need to print anything
else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "{...}");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
struct type *basetype;
int vptr_fieldno;
@@ -1620,15 +1620,33 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
/* When SHOW is zero or less, and there is a valid type name, then
always just print the type name directly from the type. */
- /* If we have "typedef struct foo {. . .} bar;" do we want to print
- it as "struct foo" or as "bar"? Pick the latter, because C++
- folk tend to expect things like "class5 *foo" rather than "struct
- class5 *foo". */
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
c_type_print_modifier (type, stream, 0, 1);
+
+ /* If we have "typedef struct foo {. . .} bar;" do we want to
+ print it as "struct foo" or as "bar"? Pick the latter for
+ C++, because C++ folk tend to expect things like "class5
+ *foo" rather than "struct class5 *foo". We rather
+ arbitrarily choose to make language_minimal work in a C-like
+ way. */
+ if (language == language_c || language == language_minimal)
+ {
+ if (TYPE_CODE (type) == TYPE_CODE_UNION)
+ fprintf_filtered (stream, "union ");
+ else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
+ {
+ if (TYPE_DECLARED_CLASS (type))
+ fprintf_filtered (stream, "class ");
+ else
+ fprintf_filtered (stream, "struct ");
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_ENUM)
+ fprintf_filtered (stream, "enum ");
+ }
+
print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
return;
}
@@ -1679,10 +1697,10 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
"{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
tag for unnamed struct/union/enum's, which we don't
want to print. */
- if (TYPE_TAG_NAME (type) != NULL
- && !startswith (TYPE_TAG_NAME (type), "{unnamed"))
+ if (TYPE_NAME (type) != NULL
+ && !startswith (TYPE_NAME (type), "{unnamed"))
{
- print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream);
+ print_name_maybe_canonical (TYPE_NAME (type), flags, stream);
if (show > 0)
fputs_filtered (" ", stream);
}
@@ -1692,10 +1710,10 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
{
/* If we just printed a tag name, no need to print anything
else. */
- if (TYPE_TAG_NAME (type) == NULL)
+ if (TYPE_NAME (type) == NULL)
fprintf_filtered (stream, "{...}");
}
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ else if (show > 0 || TYPE_NAME (type) == NULL)
{
LONGEST lastval = 0;
@@ -1804,7 +1822,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
case TYPE_CODE_NAMESPACE:
fputs_filtered ("namespace ", stream);
- fputs_filtered (TYPE_TAG_NAME (type), stream);
+ fputs_filtered (TYPE_NAME (type), stream);
break;
default: