aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2017-04-06 22:46:29 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2017-04-06 22:46:29 +0200
commited3cd38d63e8af971469f5eb551f8cfc08a83f09 (patch)
treead9d43a716508a1d3627dc4f83184c729135240b /gcc
parent926e747845a2cb5782942735d28abf479c2d825c (diff)
downloadgcc-ed3cd38d63e8af971469f5eb551f8cfc08a83f09.zip
gcc-ed3cd38d63e8af971469f5eb551f8cfc08a83f09.tar.gz
gcc-ed3cd38d63e8af971469f5eb551f8cfc08a83f09.tar.bz2
re PR debug/80234 (ICE in splice_child_die at dwarfout.c:5265)
PR debug/80234 * dwarf2out.c (gen_member_die): Handle C++17 inline static data members with redundant out-of-class redeclaration. * g++.dg/debug/dwarf2/pr80234-1.C: New test. * g++.dg/debug/dwarf2/pr80234-2.C: New test. From-SVN: r246743
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/dwarf2out.c34
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/pr80234-1.C15
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/pr80234-2.C15
5 files changed, 72 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b4bfd2e..dc518ee 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/80234
+ * dwarf2out.c (gen_member_die): Handle C++17 inline static data
+ members with redundant out-of-class redeclaration.
+
2017-04-06 Uros Bizjak <ubizjak@gmail.com>
PR target/80286
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index a00febb..8c3b186 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -24085,6 +24085,10 @@ gen_member_die (tree type, dw_die_ref context_die)
for (member = TYPE_FIELDS (type); member; member = DECL_CHAIN (member))
{
struct vlr_context vlr_ctx = { type, NULL_TREE };
+ bool static_inline_p
+ = (TREE_STATIC (member)
+ && (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline)
+ != -1));
/* If we thought we were generating minimal debug info for TYPE
and then changed our minds, some of the member declarations
@@ -24096,9 +24100,33 @@ gen_member_die (tree type, dw_die_ref context_die)
{
/* Handle inline static data members, which only have in-class
declarations. */
+ dw_die_ref ref = NULL;
+ if (child->die_tag == DW_TAG_variable
+ && child->die_parent == comp_unit_die ())
+ {
+ ref = get_AT_ref (child, DW_AT_specification);
+ /* For C++17 inline static data members followed by redundant
+ out of class redeclaration, we might get here with
+ child being the DIE created for the out of class
+ redeclaration and with its DW_AT_specification being
+ the DIE created for in-class definition. We want to
+ reparent the latter, and don't want to create another
+ DIE with DW_AT_specification in that case, because
+ we already have one. */
+ if (ref
+ && static_inline_p
+ && ref->die_tag == DW_TAG_variable
+ && ref->die_parent == comp_unit_die ()
+ && get_AT (ref, DW_AT_specification) == NULL)
+ {
+ child = ref;
+ ref = NULL;
+ static_inline_p = false;
+ }
+ }
if (child->die_tag == DW_TAG_variable
&& child->die_parent == comp_unit_die ()
- && get_AT (child, DW_AT_specification) == NULL)
+ && ref == NULL)
{
reparent_child (child, context_die);
if (dwarf_version < 5)
@@ -24126,9 +24154,7 @@ gen_member_die (tree type, dw_die_ref context_die)
/* For C++ inline static data members emit immediately a DW_TAG_variable
DIE that will refer to that DW_TAG_member/DW_TAG_variable through
DW_AT_specification. */
- if (TREE_STATIC (member)
- && (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline)
- != -1))
+ if (static_inline_p)
{
int old_extern = DECL_EXTERNAL (member);
DECL_EXTERNAL (member) = 0;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 828d82d..0cb18d4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/80234
+ * g++.dg/debug/dwarf2/pr80234-1.C: New test.
+ * g++.dg/debug/dwarf2/pr80234-2.C: New test.
+
2017-04-06 Uros Bizjak <ubizjak@gmail.com>
PR target/79733
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr80234-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr80234-1.C
new file mode 100644
index 0000000..5ab8ca8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr80234-1.C
@@ -0,0 +1,15 @@
+// PR debug/80234
+// { dg-do compile }
+// { dg-options "-gdwarf-4 -std=c++17" }
+
+struct S
+{
+ static constexpr const char n = 'S';
+ virtual ~S ();
+};
+
+constexpr const char S::n;
+
+S::~S()
+{
+}
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr80234-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr80234-2.C
new file mode 100644
index 0000000..145beac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr80234-2.C
@@ -0,0 +1,15 @@
+// PR debug/80234
+// { dg-do compile }
+// { dg-options "-gdwarf-5 -std=c++17" }
+
+struct S
+{
+ static constexpr const char n = 'S';
+ virtual ~S ();
+};
+
+constexpr const char S::n;
+
+S::~S()
+{
+}