From 98e8112376654ff5eae902ecd41a61bf0508ff73 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 16 Mar 2013 22:33:50 -0400 Subject: [PATCH] re PR debug/49090 (provide a way to recognize defaulted template parameters) PR debug/49090 * dwarf2out.c (gen_generic_params_dies): Indicate default arguments with DW_AT_default_value. From-SVN: r196723 --- gcc/ChangeLog | 6 ++++++ gcc/dwarf2out.c | 18 +++++++++++++----- gcc/langhooks.h | 6 ++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c882536e6e4..c9389843271 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-03-16 Jason Merrill + + PR debug/49090 + * dwarf2out.c (gen_generic_params_dies): Indicate default arguments + with DW_AT_default_value. + 2013-03-16 Jakub Jelinek * BASE-VER: Set to 4.9.0. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index d7faaac9f85..51e57378dad 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10238,6 +10238,7 @@ gen_generic_params_dies (tree t) tree parms, args; int parms_num, i; dw_die_ref die = NULL; + int non_default; if (!t || (TYPE_P (t) && !COMPLETE_TYPE_P (t))) return; @@ -10257,9 +10258,14 @@ gen_generic_params_dies (tree t) parms_num = TREE_VEC_LENGTH (parms); args = lang_hooks.get_innermost_generic_args (t); + if (TREE_CHAIN (args) && TREE_CODE (TREE_CHAIN (args)) == INTEGER_CST) + non_default = int_cst_value (TREE_CHAIN (args)); + else + non_default = TREE_VEC_LENGTH (args); for (i = 0; i < parms_num; i++) { tree parm, arg, arg_pack_elems; + dw_die_ref parm_die; parm = TREE_VEC_ELT (parms, i); arg = TREE_VEC_ELT (args, i); @@ -10274,12 +10280,14 @@ gen_generic_params_dies (tree t) pack elements of ARG. Note that ARG would then be an argument pack. */ if (arg_pack_elems) - template_parameter_pack_die (TREE_VALUE (parm), - arg_pack_elems, - die); + parm_die = template_parameter_pack_die (TREE_VALUE (parm), + arg_pack_elems, + die); else - generic_parameter_die (TREE_VALUE (parm), arg, - true /* Emit DW_AT_name */, die); + parm_die = generic_parameter_die (TREE_VALUE (parm), arg, + true /* emit name */, die); + if (i >= non_default) + add_AT_flag (parm_die, DW_AT_default_value, 1); } } } diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 4bc1bd571dd..80d4ef3b8a6 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -407,8 +407,10 @@ struct lang_hooks struct lang_hooks_for_lto lto; - /* Returns the generic parameters of an instantiation of - a generic type or decl, e.g. C++ template instantiation. */ + /* Returns a TREE_VEC of the generic parameters of an instantiation of + a generic type or decl, e.g. C++ template instantiation. If + TREE_CHAIN of the return value is set, it is an INTEGER_CST + indicating how many of the elements are non-default. */ tree (*get_innermost_generic_parms) (const_tree); /* Returns the TREE_VEC of arguments of an instantiation -- 2.30.2