This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto][patch] Couple of extra assertions and a testcase


This patch adds a new test case for a bug fixed by patch

  http://gcc.gnu.org/ml/gcc-patches/2009-03/msg00564.html

and inserts a couple of new assertions into symbol merging to ensure that
lto1 does not assign an assembler name when merging symbols.


gcc/ChangeLog.lto
2009-03-13  Simon Baldwin  <simonb@google.com>

	* lto-symtab.c (lto_symtab_merge_decl): Added assertion to check
	assembler name is already set.
	* (lto_symtab_prevailing_decl): Ditto.

gcc/testsuite/ChangeLog.lto
2009-03-13  Simon Baldwin  <simonb@google.com>

	* g++.dg/lto/20090313_0.C: New.
	* g++.dg/lto/20090313_1.C: New.


Index: gcc/lto-symtab.c
===================================================================
--- gcc/lto-symtab.c	(revision 144816)
+++ gcc/lto-symtab.c	(working copy)
@@ -557,6 +557,9 @@ lto_symtab_merge_decl (tree new_decl,
   /* Remember the resolution of this symbol. */
   lto_symtab_set_resolution_and_file_data (new_decl, resolution, file_data);
 
+  /* Ensure DECL_ASSEMBLER_NAME will not set assembler name.  */
+  gcc_assert (DECL_ASSEMBLER_NAME_SET_P (new_decl));
+
   /* Retrieve the previous declaration.  */
   name = DECL_ASSEMBLER_NAME (new_decl);
   old_decl = lto_symtab_get_identifier_decl (name);
@@ -648,6 +651,9 @@ lto_symtab_prevailing_decl (tree decl)
   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl))
     return decl;
 
+  /* Ensure DECL_ASSEMBLER_NAME will not set assembler name.  */
+  gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));
+
   ret = lto_symtab_get_identifier_decl (DECL_ASSEMBLER_NAME (decl));
 
   return ret;
Index: gcc/testsuite/g++.dg/lto/20090313_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20090313_0.C	(revision 0)
+++ gcc/testsuite/g++.dg/lto/20090313_0.C	(revision 0)
@@ -0,0 +1,5 @@
+// { dg-do "link" }
+// { dg-options "{-fwhopr}" }
+// { dg-extra-ld-options "-fwhopr -shared" }
+
+int X;
Index: gcc/testsuite/g++.dg/lto/20090313_1.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20090313_1.C	(revision 0)
+++ gcc/testsuite/g++.dg/lto/20090313_1.C	(revision 0)
@@ -0,0 +1,12 @@
+struct Foo {
+  virtual void X();
+  virtual void Y();
+};
+struct Bar: public Foo {
+  Bar(Foo *);
+  void Y();
+};
+void Baz() {
+  Foo f;
+  Bar b(&f);
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]