]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/37959 (g++ does not emit DW_AT_explicit)
authorDodji Seketeli <dodji@redhat.com>
Fri, 27 Mar 2009 21:44:21 +0000 (21:44 +0000)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 27 Mar 2009 21:44:21 +0000 (22:44 +0100)
PR debug/37959
* dwarf2out.c (dwarf_attr_name): Handle DW_AT_explicit attribute.
(gen_subprogram_die): When a function is explicit, generate the
DW_AT_explicit attribute.
* langhooks.h (struct lang_hooks_for_decls): Add
function_decl_explicit_p langhook.
* langhooks-def.h (LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P): Define.
(LANG_HOOKS_DECLS): Add LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P.

* cp-objcp-common.h (LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P): Define.
(cp_function_decl_explicit_p): New prototype.
* cp-objcp-common.c (cp_function_decl_explicit_p): New function.

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

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r145128

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/cp/cp-objcp-common.h
gcc/dwarf2out.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/explicit-constructor.C [new file with mode: 0644]

index 89c62b59cc0af9baf54a7773e898a9823d25e232..d7a663561cd64c14488aa43a06f5f17245801513 100644 (file)
@@ -1,3 +1,15 @@
+2009-03-27  Dodji Seketeli  <dodji@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/37959
+       * dwarf2out.c (dwarf_attr_name): Handle DW_AT_explicit attribute.
+       (gen_subprogram_die): When a function is explicit, generate the
+       DW_AT_explicit attribute.
+       * langhooks.h (struct lang_hooks_for_decls): Add
+       function_decl_explicit_p langhook.
+       * langhooks-def.h (LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P): Define.
+       (LANG_HOOKS_DECLS): Add LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P.
+
 2009-03-27  Jakub Jelinek  <jakub@redhat.com>
 
        * builtins.c (fold_builtin_memory_op): Optimize memmove
index 6fcd92a8822d311d7b58d5cbd61a5dce6146b439..477e84b7fcca612574a0d7c46e023a1ba67db337 100644 (file)
@@ -1,3 +1,11 @@
+2009-03-27  Dodji Seketeli  <dodji@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/37959
+       * cp-objcp-common.h (LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P): Define.
+       (cp_function_decl_explicit_p): New prototype.
+       * cp-objcp-common.c (cp_function_decl_explicit_p): New function.
+
 2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR c++/38638
index fefafb1ac7ea9390a6092edd0e63ef0d38526e75..daefa2b0d87fdb9df4caf4a90b7da73c5ca934f4 100644 (file)
@@ -1,5 +1,5 @@
 /* Some code common to C++ and ObjC++ front ends.
-   Copyright (C) 2004, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Ziemowit Laski  <zlaski@apple.com>
 
 This file is part of GCC.
@@ -203,6 +203,16 @@ cxx_staticp (tree arg)
   return NULL_TREE;
 }
 
+/* Return true if DECL is explicit member function.  */
+
+bool
+cp_function_decl_explicit_p (tree decl)
+{
+  return (decl
+         && FUNCTION_FIRST_USER_PARMTYPE (decl) != void_list_node
+         && DECL_NONCONVERTING_P (decl));
+}
+
 /* Stubs to keep c-opts.c happy.  */
 void
 push_file_scope (void)
index f24107598aaff0762c89f99069d0f4e198cb6382..bda23eb635b6a97b2d5d5c0c8d0556fc134544a1 100644 (file)
@@ -1,5 +1,5 @@
 /* Language hooks common to C++ and ObjC++ front ends.
-   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Ziemowit Laski  <zlaski@apple.com>
 
 This file is part of GCC.
@@ -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_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.  */
@@ -131,6 +133,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
 #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
 #undef LANG_HOOKS_GIMPLIFY_EXPR
 #define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr
+#undef LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P
+#define LANG_HOOKS_FUNCTION_DECL_EXPLICIT_P cp_function_decl_explicit_p
 #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
 #define LANG_HOOKS_OMP_PREDETERMINED_SHARING cxx_omp_predetermined_sharing
 #undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR
index 9bf0803ce5709b09706032429f6902384e845ae4..1c82f9c09ff2d66963d9bf487a4b2ff69109592c 100644 (file)
@@ -5599,6 +5599,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:
@@ -13611,6 +13613,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_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
index f9f8cde4d2a5ed520d235e1d5d7054c8540305dd..96c091c7f054c98d757d8f7c451be3f52b03dec4 100644 (file)
@@ -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_EXPLICIT_P 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_EXPLICIT_P, \
   LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
   LANG_HOOKS_WRITE_GLOBALS, \
   LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
index 52d1f24448cea22095c90527ec9122c7d5b2cbd7..4069578168307e07f2a55d70b3fba37b5d23a6a9 100644 (file)
@@ -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 DECL is explicit member function.  */
+  bool (*function_decl_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);
index 9aecc57d27eb639a7c4206f0eb60c23f3df26bd3..6898d861167c797724d1abdb8267663c21505b4e 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-27  Dodji Seketeli  <dodji@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/37959
+       * g++.dg/debug/dwarf2/explicit-constructor.C: New test.
+
 2009-03-27  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.dg/memmove-2.c: New test.
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 (file)
index 0000000..42fd264
--- /dev/null
@@ -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;
+}