pr 64076 - tolerate different definitions of symbols in lto
diff mbox

Message ID 1421804284-19745-1-git-send-email-tbsaunde+gcc@tbsaunde.org
State New
Headers show

Commit Message

tbsaunde+gcc@tbsaunde.org Jan. 21, 2015, 1:38 a.m. UTC
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Hi,

Same patch as before, but now with a test case.

I checked this fails without the patch and passes with it, ok?

Trev

gcc/

	* ipa-visibility.c (update_visibility_by_resolution_info): Only
	assert when not in lto mode.
---
 gcc/ipa-visibility.c                 | 18 +++++++++++++-----
 gcc/testsuite/g++.dg/lto/pr64076.H   | 20 ++++++++++++++++++++
 gcc/testsuite/g++.dg/lto/pr64076_0.C | 10 ++++++++++
 gcc/testsuite/g++.dg/lto/pr64076_1.C |  5 +++++
 4 files changed, 48 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/lto/pr64076.H
 create mode 100644 gcc/testsuite/g++.dg/lto/pr64076_0.C
 create mode 100644 gcc/testsuite/g++.dg/lto/pr64076_1.C

Patch
diff mbox

diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
index 71894af..0791a1c 100644
--- a/gcc/ipa-visibility.c
+++ b/gcc/ipa-visibility.c
@@ -425,11 +425,19 @@  update_visibility_by_resolution_info (symtab_node * node)
   if (node->same_comdat_group)
     for (symtab_node *next = node->same_comdat_group;
 	 next != node; next = next->same_comdat_group)
-      gcc_assert (!next->externally_visible
-		  || define == (next->resolution == LDPR_PREVAILING_DEF_IRONLY
-			        || next->resolution == LDPR_PREVAILING_DEF
-			        || next->resolution == LDPR_UNDEF
-			        || next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP));
+      {
+	if (!next->externally_visible)
+	  continue;
+
+	bool same_def
+	  = define == (next->resolution == LDPR_PREVAILING_DEF_IRONLY
+		       || next->resolution == LDPR_PREVAILING_DEF
+		       || next->resolution == LDPR_UNDEF
+		       || next->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP);
+	gcc_assert (in_lto_p || same_def);
+	if (!same_def)
+	  return;
+      }
 
   if (node->same_comdat_group)
     for (symtab_node *next = node->same_comdat_group;
diff --git a/gcc/testsuite/g++.dg/lto/pr64076.H b/gcc/testsuite/g++.dg/lto/pr64076.H
new file mode 100644
index 0000000..6afe37a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr64076.H
@@ -0,0 +1,20 @@ 
+struct Base {
+  virtual void f() = 0;
+};
+
+struct X : public Base { };
+struct Y : public Base { };
+struct Z : public Base { };
+struct T : public Base { };
+
+struct S : public X, public Y, public Z
+#ifdef XXX
+, public T
+#endif
+{
+  void f()
+#ifdef XXX
+  { }
+#endif
+  ;
+};
diff --git a/gcc/testsuite/g++.dg/lto/pr64076_0.C b/gcc/testsuite/g++.dg/lto/pr64076_0.C
new file mode 100644
index 0000000..fb9b060
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr64076_0.C
@@ -0,0 +1,10 @@ 
+// { dg-lto-do link }
+
+#define XXX
+#include "pr64076.H"
+
+int main()
+{
+  S s;
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/lto/pr64076_1.C b/gcc/testsuite/g++.dg/lto/pr64076_1.C
new file mode 100644
index 0000000..4bd0081
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr64076_1.C
@@ -0,0 +1,5 @@ 
+// { dg-options -fno-lto }
+
+#include "pr64076.H"
+
+void S::f() { }