aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-11-20 10:03:45 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-11-20 10:03:45 +0100
commitec5a0fe0422d6f472d75528a14bd22511914e240 (patch)
treeeae3caec19e186893cd194cc99911961fda5e602 /gcc/cp
parent511f5bb114913b7cdaa78cb60ed46d0d5a27f5e3 (diff)
downloadgcc-ec5a0fe0422d6f472d75528a14bd22511914e240.zip
gcc-ec5a0fe0422d6f472d75528a14bd22511914e240.tar.gz
gcc-ec5a0fe0422d6f472d75528a14bd22511914e240.tar.bz2
re PR c++/67354 (internal compiler error: in add_to_same_comdat_group, at symtab.c:421)
PR c++/67354 * cp-tree.h (defer_mangling_aliases): Declare. (generate_mangling_aliases): New prototype. * decl2.c (defer_mangling_aliases): New variable. (note_mangling_alias): Use !defer_mangling_aliases instead of at_eof. (generate_mangling_aliases): No longer static. Clear defer_mangling_aliases. * optimize.c (maybe_thunk_body): Defer emitting mangling aliases if !defer_mangling_aliases until the fns are put into the same comdat group. * g++.dg/abi/mangle67.C: New test. From-SVN: r230646
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/decl2.c12
-rw-r--r--gcc/cp/optimize.c7
4 files changed, 37 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cf436d7..0428c3c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,17 @@
+2015-11-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/67354
+ * cp-tree.h (defer_mangling_aliases): Declare.
+ (generate_mangling_aliases): New prototype.
+ * decl2.c (defer_mangling_aliases): New variable.
+ (note_mangling_alias): Use !defer_mangling_aliases
+ instead of at_eof.
+ (generate_mangling_aliases): No longer static. Clear
+ defer_mangling_aliases.
+ * optimize.c (maybe_thunk_body): Defer emitting mangling aliases
+ if !defer_mangling_aliases until the fns are put into the same
+ comdat group.
+
2015-11-19 David Malcolm <dmalcolm@redhat.com>
* cp-tree.h (lookup_member_fuzzy): New decl.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 38bd7dd..1672291 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4846,6 +4846,11 @@ extern GTY(()) vec<tree, va_gc> *local_classes;
extern int at_eof;
+/* True if note_mangling_alias should enqueue mangling aliases for
+ later generation, rather than emitting them right away. */
+
+extern bool defer_mangling_aliases;
+
/* A list of namespace-scope objects which have constructors or
destructors which reside in the global scope. The decl is stored
in the TREE_VALUE slot and the initializer is stored in the
@@ -5772,6 +5777,7 @@ extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t);
/* in decl2.c */
extern void note_mangling_alias (tree, tree);
+extern void generate_mangling_aliases (void);
extern bool check_java_method (tree);
extern tree build_memfn_type (tree, tree, cp_cv_quals, cp_ref_qualifier);
extern tree build_pointer_ptrmemfn_type (tree);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 47c9ec9..2cc51d6 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -102,6 +102,11 @@ static GTY(()) vec<tree, va_gc> *mangling_aliases;
/* Nonzero if we're done parsing and into end-of-file activities. */
int at_eof;
+
+/* True if note_mangling_alias should enqueue mangling aliases for
+ later generation, rather than emitting them right away. */
+
+bool defer_mangling_aliases = true;
/* Return a member function type (a METHOD_TYPE), given FNTYPE (a
@@ -4389,7 +4394,7 @@ void
note_mangling_alias (tree decl ATTRIBUTE_UNUSED, tree id2 ATTRIBUTE_UNUSED)
{
#ifdef ASM_OUTPUT_DEF
- if (at_eof)
+ if (!defer_mangling_aliases)
generate_mangling_alias (decl, id2);
else
{
@@ -4399,7 +4404,9 @@ note_mangling_alias (tree decl ATTRIBUTE_UNUSED, tree id2 ATTRIBUTE_UNUSED)
#endif
}
-static void
+/* Emit all mangling aliases that were deferred up to this point. */
+
+void
generate_mangling_aliases ()
{
while (!vec_safe_is_empty (mangling_aliases))
@@ -4408,6 +4415,7 @@ generate_mangling_aliases ()
tree decl = mangling_aliases->pop();
generate_mangling_alias (decl, id2);
}
+ defer_mangling_aliases = false;
}
/* The entire file is now complete. If requested, dump everything
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index c4e7020..a5f84a0 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -270,7 +270,11 @@ maybe_thunk_body (tree fn, bool force)
}
else if (HAVE_COMDAT_GROUP)
{
+ /* At eof, defer creation of mangling aliases temporarily. */
+ bool save_defer_mangling_aliases = defer_mangling_aliases;
+ defer_mangling_aliases = true;
tree comdat_group = cdtor_comdat_group (fns[1], fns[0]);
+ defer_mangling_aliases = save_defer_mangling_aliases;
cgraph_node::get_create (fns[0])->set_comdat_group (comdat_group);
cgraph_node::get_create (fns[1])->add_to_same_comdat_group
(cgraph_node::get_create (fns[0]));
@@ -281,6 +285,9 @@ maybe_thunk_body (tree fn, bool force)
virtual, it goes into the same comdat group as well. */
cgraph_node::get_create (fns[2])->add_to_same_comdat_group
(symtab_node::get (fns[0]));
+ /* Emit them now that the thunks are same comdat group aliases. */
+ if (!save_defer_mangling_aliases)
+ generate_mangling_aliases ();
TREE_PUBLIC (fn) = false;
DECL_EXTERNAL (fn) = false;
DECL_INTERFACE_KNOWN (fn) = true;