Comment 1 for bug 662324

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

So, to add c1's type, we call gen_typedef_with_usage with A typedef variant.
19880 /* If TYPE is a typedef type variant, let's generate debug info
19881 for the parent typedef which TYPE is a type of. */
19882 if (typedef_variant_p (type))
19883 {
19884 if (TREE_ASM_WRITTEN (type))
19885 return;
19886
19887 /* Prevent broken recursion; we can't hand off to the same type. */
19888 gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type);
19889
19890 /* Use the DIE of the containing namespace as the parent DIE of
19891 the type description DIE we want to generate. */
19892 if (DECL_CONTEXT (TYPE_NAME (type))
19893 && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)
19894 context_die = get_context_die (DECL_CONTEXT (TYPE_NAME (type)));
19895
19896 TREE_ASM_WRITTEN (type) = 1;
19897
19898 gen_decl_die (TYPE_NAME (type), NULL, context_die);
19899 return;

TREE_ASM_WRITTEN is not set on type originally, we compute context_die. Then set TREE_ASM_WRITTEN and call gen_decl_die. TYPE_NAME (type) is a redundant typedef though, so in gen_decl_die:
20544 if (is_redundant_typedef (decl))
20545 gen_type_die (TREE_TYPE (decl), context_die);
and TREE_TYPE (decl) here is the type on which we've just set TREE_ASM_WRITTEN, so gen_type_die_with_usage is recursed with the same type and as TREE_ASM_WRITTEN is now already set, it returns immediately, without creating any type. So, I think we need to special case is_redundant_typedef (TYPE_NAME (type))) in gen_type_die_with_usage in the typedef_variant_p (type) handling and ensure we actually create the DECL_ORIGINAL_TYPE in that case and equate that also to the underlying type. Or this could be a bug in the FE.