This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR debug/37959


Jason Merrill a écrit :
(cp_function_decl_is_constructor_p): New function.

Wrong one :)

Oops, fixed in the attached patch.


Other than that, this looks good, but you'll need to get an OK from a release manager to check it in on the trunk since it isn't a regression.

I think I'll just wait for trunk to re-open again then :)


Thanks,

Dodji.

gcc/ChangeLog:
2008-10-31  Dodji Seketeli  <dodji@redhat.com>

	* dwarf2out.c (dwarf_attr_name): Learn about DW_AT_explicit attribute.
	(gen_subprogram_die): When a function is explicit, generate the DW_AT_explicit
	attribute.
	* langhooks.h: Add a hook to let the debug backend query the front end about
	if a function decl is explicit.

gcc/cp/ChangeLog:
2008-10-31  Dodji Seketeli  <dodji@redhat.com>

	* PR debug/37959
	* cp-lang.c: Set the new lang hook LANG_HOOKS_FUNCTION_DECL_IS_EXPLICIT
	for the c++ FE.
	(cp_function_decl_is_explicit_p): New function.

gcc/testsuite/ChangeLog:
2008-10-31  Dodji Seketeli  <dodji@redhat.com>

	PR debug/37959
	* g++.dg/debug/dwarf2/explicit-constructor.C: New test.

diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index b30ad81..5e5f000 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -57,6 +57,8 @@ static enum classify_record cp_classify_record (tree type);
 #define LANG_HOOKS_FOLD_OBJ_TYPE_REF cp_fold_obj_type_ref
 #undef LANG_HOOKS_INIT_TS
 #define LANG_HOOKS_INIT_TS cp_init_ts
+#undef  LANG_HOOKS_FUNCTION_DECL_IS_EXPLICIT
+#define LANG_HOOKS_FUNCTION_DECL_IS_EXPLICIT cp_function_decl_is_explicit_p
 
 /* Each front end provides its own lang hook initializer.  */
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
@@ -124,6 +126,15 @@ cp_classify_record (tree type)
   return RECORD_IS_STRUCT;
 }
 
+/* This is the c++ implementation of
+   lang_hooks.decl.function_decl_is_explicit_p declared in gcc/langhooks.  */
+bool
+cp_function_decl_is_explicit_p (tree decl)
+{
+  return (decl && FUNCTION_FIRST_USER_PARMTYPE (decl) != void_list_node
+	  && DECL_NONCONVERTING_P (decl));
+}
+
 void
 finish_file (void)
 {
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index db78f94..3900f1e 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -26,6 +26,8 @@ along with GCC; see the file COPYING3.  If not see
 extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
 					 tree, bool);
 
+extern bool cp_function_decl_is_explicit_p (tree decl);
+
 /* Lang hooks that are shared between C++ and ObjC++ are defined here.  Hooks
    specific to C++ or ObjC++ go in cp/cp-lang.c and objcp/objcp-lang.c,
    respectively.  */
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 614871e..d81ce03 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5549,6 +5549,8 @@ dwarf_attr_name (unsigned int attr)
       return "DW_AT_encoding";
     case DW_AT_external:
       return "DW_AT_external";
+    case DW_AT_explicit:
+      return "DW_AT_explicit";
     case DW_AT_frame_base:
       return "DW_AT_frame_base";
     case DW_AT_friend:
@@ -13624,6 +13626,11 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
 	{
 	  add_AT_flag (subr_die, DW_AT_declaration, 1);
 
+	  /* If this is an explicit function declaration then generate
+	     a DW_AT_explicit attribute.  */
+          if (lang_hooks.decls.function_decl_is_explicit_p (decl))
+	    add_AT_flag (subr_die, DW_AT_explicit, 1);
+
 	  /* The first time we see a member function, it is in the context of
 	     the class to which it belongs.  We make sure of this by emitting
 	     the class first.  The next time is the definition, which is
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 996e2f2..11da544 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -189,6 +189,7 @@ extern tree lhd_make_node (enum tree_code);
 #define LANG_HOOKS_GLOBAL_BINDINGS_P global_bindings_p
 #define LANG_HOOKS_PUSHDECL	pushdecl
 #define LANG_HOOKS_GETDECLS	getdecls
+#define LANG_HOOKS_FUNCTION_DECL_IS_EXPLICIT hook_bool_tree_false
 #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
 #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
 #define LANG_HOOKS_DECL_OK_FOR_SIBCALL	lhd_decl_ok_for_sibcall
@@ -208,6 +209,7 @@ extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_GLOBAL_BINDINGS_P, \
   LANG_HOOKS_PUSHDECL, \
   LANG_HOOKS_GETDECLS, \
+  LANG_HOOKS_FUNCTION_DECL_IS_EXPLICIT, \
   LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
   LANG_HOOKS_WRITE_GLOBALS, \
   LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 752ad99..a192216 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -159,6 +159,9 @@ struct lang_hooks_for_decls
   /* Returns the chain of decls so far in the current scope level.  */
   tree (*getdecls) (void);
 
+  /* Returns true if the constructor is explicit.  */
+  bool (*function_decl_is_explicit_p) (tree);
+
   /* Returns true when we should warn for an unused global DECL.
      We will already have checked that it has static binding.  */
   bool (*warn_unused_global) (const_tree);
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/explicit-constructor.C b/gcc/testsuite/g++.dg/debug/dwarf2/explicit-constructor.C
new file mode 100644
index 0000000..ba0c162
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/explicit-constructor.C
@@ -0,0 +1,19 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++
+// { dg-do compile }
+// { dg-options "-O -g -dA" }
+// { dg-final { scan-assembler-times "DW_AT_explicit" "2" } }
+
+struct Foo
+{
+  Foo () {}
+  explicit Foo (int) {}
+  Foo (char) {}
+  ~Foo () {};
+};
+
+void
+bar ()
+{
+  Foo foo;
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]