re PR debug/49090 (provide a way to recognize defaulted template parameters)
authorJason Merrill <jason@redhat.com>
Sun, 17 Mar 2013 02:33:50 +0000 (22:33 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 17 Mar 2013 02:33:50 +0000 (22:33 -0400)
PR debug/49090
* dwarf2out.c (gen_generic_params_dies): Indicate default arguments
with DW_AT_default_value.

From-SVN: r196723

gcc/ChangeLog
gcc/dwarf2out.c
gcc/langhooks.h

index c882536e6e475939ea6bf08bf4eea1d345ed3060..c9389843271d341ae9837ce1c1e97618004bff9b 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-16  Jason Merrill  <jason@redhat.com>
+
+       PR debug/49090
+       * dwarf2out.c (gen_generic_params_dies): Indicate default arguments
+       with DW_AT_default_value.
+
 2013-03-16  Jakub Jelinek  <jakub@redhat.com>
 
        * BASE-VER: Set to 4.9.0.
index d7faaac9f85905475d4fe709c5e8beeb1979e89f..51e57378dad7127fc5ddce52f07ebd66cd7d0565 100644 (file)
@@ -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);
        }
     }
 }
index 4bc1bd571dd09defd8b6a1fce09d876c26cb13de..80d4ef3b8a68060c3f5ef82cce5d94f9d85ed1b7 100644 (file)
@@ -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