Patchwork [windows] : PR target/40068

login
register
mail settings
Submitter Kai Tietz
Date Feb. 2, 2012, 8:46 p.m.
Message ID <CAEwic4Y5drwZfJzKAYenfg20vXYQU2AXBJLfK4VmJNQQ3icUew@mail.gmail.com>
Download mbox | patch
Permalink /patch/139216/
State New
Headers show

Comments

Kai Tietz - Feb. 2, 2012, 8:46 p.m.
Hi,

the following patch -  Dave it is a derived variant from on of your
patches for a similar issue - takes care that for dllexport'ed classes
the typeinfo base declaration gets the dllexport-attribute, too.

ChangeLog

2012-02-02  Kai Tietz  <ktietz@redhat.com>
                  Dave Korn

	* config/i386/winnt-cxx.c (i386_pe_adjust_class_at_definition):
	Take care that typinfo gets dllexport-attribute.

Regression tested for i686-w64-mingw32, and x86_64-w64-mingw32.  If
there is no objection within next 4 days, I will apply this patch.

Regards,
Kai

Patch

Index: gcc/gcc/config/i386/winnt-cxx.c
===================================================================
--- gcc.orig/gcc/config/i386/winnt-cxx.c
+++ gcc/gcc/config/i386/winnt-cxx.c
@@ -97,6 +97,20 @@  i386_pe_adjust_class_at_definition (tree

   if (lookup_attribute ("dllexport", TYPE_ATTRIBUTES (t)) != NULL_TREE)
     {
+      tree tmv = TYPE_MAIN_VARIANT (t);
+
+      /* Make sure that we set dllexport attribute to typeinfo's
+	 base declaration, as otherwise it would fail to be exported as
+	 it isn't a class-member.  */
+      if (tmv != NULL_TREE
+	  && CLASS_TYPE_TYPEINFO_VAR (tmv) != NULL_TREE)
+	{
+	  tree na, ti_decl = CLASSTYPE_TYPEINFO_VAR (tmv);
+	  na = tree_cons (get_identifier ("dllexport"), NULL_TREE,
+			  NULL_TREE);
+	  decl_attributes (&ti_decl, na, 0);
+	}
+
       /* Check static VAR_DECL's.  */
       for (member = TYPE_FIELDS (t); member; member = DECL_CHAIN (member))
 	if (TREE_CODE (member) == VAR_DECL)