Hi,
in this bug we ICE in dwarf2out.c:is_base_type with -g, because it
doesn't know how to handle the TEMPLATE_TYPE_PARM coming from the C++
front-end and representing 'auto' in this kind of C++1y code.
That it shouldn't ICE and return 0 instead I'm pretty sure, I'm less
sure about the next problem, that is what gen_type_die_with_usage should
do: build a DW_TAG_unspecified_type, like happens for NULLPTR_TYPE or
LANG_TYPE?!? Anyway, my wild guessing resulted in adding an hook, per
the below draft (in any case, tentative names and comments but passes
testing). Or we want something completely different?
Thanks,
Paolo.
///
Index: cp/cp-lang.c
===
--- cp/cp-lang.c(revision 207048)
+++ cp/cp-lang.c(working copy)
@@ -68,6 +68,9 @@ static tree get_template_argument_pack_elems_folde
#undef LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P
#define LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P \
template_template_parameter_p
+#undef LANG_HOOKS_IS_AUTO
+#define LANG_HOOKS_IS_AUTO \
+ is_auto
#undef LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P
#define LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P \
function_parameter_expanded_from_pack_p
Index: dwarf2out.c
===
--- dwarf2out.c (revision 207048)
+++ dwarf2out.c (working copy)
@@ -10222,6 +10222,9 @@ base_type_die (tree type)
static inline int
is_base_type (tree type)
{
+ if (lang_hooks.decls.is_auto (type))
+return 0;
+
switch (TREE_CODE (type))
{
case ERROR_MARK:
@@ -19653,6 +19656,23 @@ gen_tagged_type_die (tree type,
when appropriate. */
}
+/* Generate a DIE for an unspecified type. */
+
+static void
+gen_unspecified_type_die (tree type)
+{
+ dw_die_ref type_die = lookup_type_die (type);
+ if (type_die == NULL)
+{
+ tree name = TYPE_NAME (type);
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+ type_die = new_die (DW_TAG_unspecified_type, comp_unit_die (), type);
+ add_name_attribute (type_die, IDENTIFIER_POINTER (name));
+ equate_type_number_to_die (type, type_die);
+}
+}
+
/* Generate a type description DIE. */
static void
@@ -19718,6 +19738,13 @@ gen_type_die_with_usage (tree type, dw_die_ref con
return;
}
+ if (lang_hooks.decls.is_auto (type))
+{
+ gen_unspecified_type_die (type);
+ TREE_ASM_WRITTEN (type) = 1;
+ return;
+}
+
/* We are going to output a DIE to represent the unqualified version
of this type (i.e. without any const or volatile qualifiers) so
get the main variant (i.e. the unqualified version) of this type
@@ -19805,18 +19832,7 @@ gen_type_die_with_usage (tree type, dw_die_ref con
case NULLPTR_TYPE:
case LANG_TYPE:
/* Just use DW_TAG_unspecified_type. */
- {
-dw_die_ref type_die = lookup_type_die (type);
-if (type_die == NULL)
- {
- tree name = TYPE_NAME (type);
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-type_die = new_die (DW_TAG_unspecified_type, comp_unit_die (),
type);
-add_name_attribute (type_die, IDENTIFIER_POINTER (name));
-equate_type_number_to_die (type, type_die);
- }
- }
+ gen_unspecified_type_die (type);
break;
default:
Index: langhooks-def.h
===
--- langhooks-def.h (revision 207048)
+++ langhooks-def.h (working copy)
@@ -159,6 +159,7 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_FUNCTION_PARAMETER_PACK_P hook_bool_const_tree_false
#define LANG_HOOKS_GET_ARGUMENT_PACK_ELEMS hook_tree_const_tree_null
#define LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P hook_bool_const_tree_false
+#define LANG_HOOKS_IS_AUTO hook_bool_const_tree_false
#define LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P \
hook_bool_tree_tree_false
#define LANG_HOOKS_GET_GENERIC_FUNCTION_DECL hook_tree_const_tree_null
@@ -220,6 +221,7 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_GETDECLS, \
LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P, \
LANG_HOOKS_GENERIC_GENERIC_PARAMETER_DECL_P, \
+ LANG_HOOKS_IS_AUTO, \
LANG_HOOKS_FUNCTION_PARM_EXPANDED_FROM_PACK_P, \
LANG_HOOKS_GET_GENERIC_FUNCTION_DECL, \
LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
Index: langhooks.h
===
--- langhooks.h (revision 207048)
+++ langhooks.h (working copy)
@@ -164,6 +164,9 @@ struct lang_hooks_for_decls
of a generic type, e.g a template template parameter for the C++ FE. */
bool (*generic_generic_parameter_decl_p) (const_tree);
+ /* Returns true if the parameter represents 'auto' or 'decltype(auto)'. */
+ bool (*is_auto) (const_tree);
+
/* Determine if a function