- c_type_print_modifier (type, stream, 0, 1);
- fprintf_filtered (stream, "union ");
-
- struct_union:
-
- /* Print the tag if it exists.
- * The HP aCC compiler emits
- * a 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
- && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
- {
- fputs_filtered (TYPE_TAG_NAME (type), stream);
- if (show > 0)
- fputs_filtered (" ", stream);
- }
- wrap_here (" ");
- if (show < 0)
- {
- /* If we just printed a tag name, no need to print anything else. */
- if (TYPE_TAG_NAME (type) == NULL)
- fprintf_filtered (stream, "{...}");
- }
- else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
- {
- struct type *basetype;
- int vptr_fieldno;
-
- cp_type_print_derivation_info (stream, type);
-
- fprintf_filtered (stream, "{\n");
- if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
- {
- if (TYPE_STUB (type))
- fprintfi_filtered (level + 4, stream, _("<incomplete type>\n"));
- else
- fprintfi_filtered (level + 4, stream, _("<no data fields>\n"));
- }
-
- /* Start off with no specific section type, so we can print
- one for the first field we find, and use that section type
- thereafter until we find another type. */
-
- section_type = s_none;
-
- /* For a class, if all members are private, there's no need
- for a "private:" label; similarly, for a struct or union
- masquerading as a class, if all members are public, there's
- no need for a "public:" label. */
-
- if (TYPE_DECLARED_CLASS (type))
- {
- QUIT;
- len = TYPE_NFIELDS (type);
- for (i = TYPE_N_BASECLASSES (type); i < len; i++)
- if (!TYPE_FIELD_PRIVATE (type, i))
- {
- need_access_label = 1;
- break;
- }
- QUIT;
- if (!need_access_label)
- {
- len2 = TYPE_NFN_FIELDS (type);
- for (j = 0; j < len2; j++)
+ {
+ struct type_print_options local_flags = *flags;
+ struct type_print_options semi_local_flags = *flags;
+ struct cleanup *local_cleanups = make_cleanup (null_cleanup, NULL);
+
+ local_flags.local_typedefs = NULL;
+ semi_local_flags.local_typedefs = NULL;
+
+ if (!flags->raw)
+ {
+ if (flags->local_typedefs)
+ local_flags.local_typedefs
+ = copy_typedef_hash (flags->local_typedefs);
+ else
+ local_flags.local_typedefs = create_typedef_hash ();
+
+ make_cleanup_free_typedef_hash (local_flags.local_typedefs);
+ }
+
+ c_type_print_modifier (type, stream, 0, 1);
+ if (TYPE_CODE (type) == TYPE_CODE_UNION)
+ fprintf_filtered (stream, "union ");
+ else if (TYPE_DECLARED_CLASS (type))
+ fprintf_filtered (stream, "class ");
+ else
+ fprintf_filtered (stream, "struct ");
+
+ /* Print the tag if it exists. The HP aCC compiler emits a
+ 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
+ && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8))
+ {
+ /* 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);
+ if (show > 0)
+ fputs_filtered (" ", stream);
+ }
+
+ if (show < 0)
+ {
+ /* If we just printed a tag name, no need to print anything
+ else. */
+ if (TYPE_TAG_NAME (type) == NULL)
+ fprintf_filtered (stream, "{...}");
+ }
+ else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
+ {
+ struct type *basetype;
+ int vptr_fieldno;
+
+ c_type_print_template_args (&local_flags, type, stream);
+
+ /* Add in template parameters when printing derivation info. */
+ add_template_parameters (local_flags.local_typedefs, type);
+ cp_type_print_derivation_info (stream, type, &local_flags);
+
+ /* This holds just the global typedefs and the template
+ parameters. */
+ semi_local_flags.local_typedefs
+ = copy_typedef_hash (local_flags.local_typedefs);
+ if (semi_local_flags.local_typedefs)
+ make_cleanup_free_typedef_hash (semi_local_flags.local_typedefs);
+
+ /* Now add in the local typedefs. */
+ recursively_update_typedef_hash (local_flags.local_typedefs, type);
+
+ fprintf_filtered (stream, "{\n");
+ if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0
+ && TYPE_TYPEDEF_FIELD_COUNT (type) == 0)
+ {
+ if (TYPE_STUB (type))
+ fprintfi_filtered (level + 4, stream,
+ _("<incomplete type>\n"));
+ else
+ fprintfi_filtered (level + 4, stream,
+ _("<no data fields>\n"));
+ }
+
+ /* Start off with no specific section type, so we can print
+ one for the first field we find, and use that section type
+ thereafter until we find another type. */
+
+ section_type = s_none;
+
+ /* For a class, if all members are private, there's no need
+ for a "private:" label; similarly, for a struct or union
+ masquerading as a class, if all members are public, there's
+ no need for a "public:" label. */
+
+ if (TYPE_DECLARED_CLASS (type))
+ {
+ QUIT;
+ len = TYPE_NFIELDS (type);
+ for (i = TYPE_N_BASECLASSES (type); i < len; i++)
+ if (!TYPE_FIELD_PRIVATE (type, i))