From c8572dd688e71e4e8376b270aed5d4f6217d9b54 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Fri, 3 Jun 2016 20:42:08 +0000 Subject: [PATCH] re PR c++/27100 (ICE with multiple friend declarations) Fix PR c++/27100 gcc/cp/ChangeLog: PR c++/27100 * decl.c (duplicate_decls): Properly copy the DECL_PENDING_INLINE_P, DECL_PENDING_INLINE_INFO and DECL_SAVED_FUNCTION_DATA fields from OLDDECL to NEWDECL. gcc/testsuite/ChangeLog: PR c++/27100 * g++.dg/other/friend6.C: New test. From-SVN: r237078 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/decl.c | 13 +++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/friend6.C | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/friend6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bec708c..0569d84 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-06-03 Patrick Palka + + PR c++/27100 + * decl.c (duplicate_decls): Properly copy the + DECL_PENDING_INLINE_P, DECL_PENDING_INLINE_INFO and + DECL_SAVED_FUNCTION_DATA fields from OLDDECL to NEWDECL. + 2016-06-03 Chung-Lin Tang * semantics.c (finish_omp_clauses): Mark OpenACC reduction diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cd7143b..3328e71 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2351,8 +2351,17 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } else { - if (DECL_PENDING_INLINE_INFO (newdecl) == 0) - DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl); + if (DECL_PENDING_INLINE_P (olddecl)) + { + DECL_PENDING_INLINE_P (newdecl) = 1; + DECL_PENDING_INLINE_INFO (newdecl) + = DECL_PENDING_INLINE_INFO (olddecl); + } + else if (DECL_PENDING_INLINE_P (newdecl)) + ; + else if (DECL_SAVED_FUNCTION_DATA (newdecl) == NULL) + DECL_SAVED_FUNCTION_DATA (newdecl) + = DECL_SAVED_FUNCTION_DATA (olddecl); DECL_DECLARED_INLINE_P (newdecl) |= DECL_DECLARED_INLINE_P (olddecl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ea1576b..659477b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-03 Patrick Palka + + PR c++/27100 + * g++.dg/other/friend6.C: New test. + 2016-06-03 Bill Schmidt * g++.dg/torture/ppc-ldst-array.C: New. diff --git a/gcc/testsuite/g++.dg/other/friend6.C b/gcc/testsuite/g++.dg/other/friend6.C new file mode 100644 index 0000000..851cd25 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend6.C @@ -0,0 +1,15 @@ +// PR c++/27100 +// This used to fail at link time with an "undefined reference to 'foo'" error. +// { dg-do run } + +struct A +{ + friend void foo (const A&) { } + friend void foo (const A&); +}; + +int +main () +{ + foo (A ()); +} -- 2.7.4