From: Jason Merrill Date: Thu, 28 Feb 2019 17:29:48 +0000 (-0500) Subject: PR c++/88049 - ICE with undefined destructor and anon namespace. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=80f52b400e1fc770c96d5e28ac7343aac3733df9;p=gcc.git PR c++/88049 - ICE with undefined destructor and anon namespace. A type in an anonymous namespace can never be merged with one from another translation unit, so a member of such a type is always its own prevailing decl. * lto-symtab.c (lto_symtab_prevailing_virtual_decl): Return early for a type in an anonymous namespace. From-SVN: r269283 --- diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 6b183df3b0f..f8a1bbec763 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2019-02-28 Jason Merrill + + PR c++/88049 - ICE with undefined destructor and anon namespace. + * lto-symtab.c (lto_symtab_prevailing_virtual_decl): Return early + for a type in an anonymous namespace. + 2019-01-09 Sandra Loosemore PR other/16615 diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c index 22da4c78b8c..343915c3cec 100644 --- a/gcc/lto/lto-symtab.c +++ b/gcc/lto/lto-symtab.c @@ -1085,8 +1085,12 @@ lto_symtab_prevailing_virtual_decl (tree decl) { if (DECL_ABSTRACT_P (decl)) return decl; - gcc_checking_assert (!type_in_anonymous_namespace_p (DECL_CONTEXT (decl)) - && DECL_ASSEMBLER_NAME_SET_P (decl)); + + if (type_in_anonymous_namespace_p (DECL_CONTEXT (decl))) + /* There can't be any other declarations. */ + return decl; + + gcc_checking_assert (DECL_ASSEMBLER_NAME_SET_P (decl)); symtab_node *n = symtab_node::get_for_asmname (DECL_ASSEMBLER_NAME (decl)); diff --git a/gcc/testsuite/g++.dg/lto/pr88049_0.C b/gcc/testsuite/g++.dg/lto/pr88049_0.C new file mode 100644 index 00000000000..7ac3618c2c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr88049_0.C @@ -0,0 +1,16 @@ +// PR c++/88049 +// { dg-lto-do link } +// { dg-lto-options {{ -flto -O2 -w }} } +// { dg-extra-ld-options -r } + +template class a; +class b {}; +template a d(char); +template class a : public b { +public: + virtual ~a(); +}; +namespace { + class f; + b c = d(int()); +} // namespace