re PR c++/9738 ([mingw] Internal compiler error in rest_of_compilation, at toplev...
authorDanny Smith <dannysmith@users.sourceforge.net>
Wed, 21 May 2003 00:33:27 +0000 (00:33 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Wed, 21 May 2003 00:33:27 +0000 (00:33 +0000)
PR c++/9738

* config/i386/winnt.c (i386_pe_encode_section_info): Enable
even if not first.

* cp/decl.c (duplicate_decls): Re-invoke make_decl_rtl
if the old decl had instantiated DECL_RTL.
(Base on Richard Henderson 2003-05-13 patch to c-decl.c).

* testsuite/g++.dg/ext/dllimport2.C: New file.
* testsuite/g++.dg/ext/dllimport3.C: New file.

From-SVN: r67049

gcc/ChangeLog
gcc/config/i386/winnt.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/dllimport2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/dllimport3.C [new file with mode: 0644]

index 59c182cca22c722144d1f4430da669f625fbbf83..c5c1792e147e32e96fd88a2d85b691f0faf9a75c 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-21  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR c++/9738
+       * config/i386/winnt.c (i386_pe_encode_section_info): Enable
+       even if not first.
+
 2003-05-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * genautomata.c (output_description, output_automaton_units,
index c2eac3ac7e2dfbac53e376afc2ba8d27df48820a..04f5cedb036338f380a7081c4a01c7f19074137f 100644 (file)
@@ -427,9 +427,6 @@ i386_pe_encode_section_info (decl, rtl, first)
      rtx rtl;
      int first;
 {
-  if (!first)
-    return;
-
   default_encode_section_info (decl, rtl, first);
 
   if (TREE_CODE (decl) == FUNCTION_DECL)
@@ -445,7 +442,8 @@ i386_pe_encode_section_info (decl, rtl, first)
     }
 
   /* Mark the decl so we can tell from the rtl whether the object is
-     dllexport'd or dllimport'd.  */
+     dllexport'd or dllimport'd.  This also handles dllexport/dllimport
+     override semantics.   */
 
   if (i386_pe_dllexport_p (decl))
     i386_pe_mark_dllexport (decl);
index 15a0eb60e01110e9f7342999bcca1112ddba11b2..7ea230f968c0a80ce0f4585e7ea5fcb2fcf88767 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-21  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR c++/9738
+       * decl.c (duplicate_decls): Re-invoke make_decl_rtl
+       if the old decl had instantiated DECL_RTL.
+       (Base on Richard Henderson 2003-05-13 patch to c-decl.c).
+
 2003-05-19  Matt Austern  <austern@apple.com>
 
        * lang-options.h: Document -Wno-invalid-offsetof
index 48f4a8cf58ea8e56f852214dbfb6cb518f1d6f1b..71a582277050636cc46fc3c13f2d1f4693e2b68f 100644 (file)
@@ -3593,6 +3593,15 @@ duplicate_decls (tree newdecl, tree olddecl)
      Update OLDDECL to be the same.  */
   DECL_ATTRIBUTES (olddecl) = DECL_ATTRIBUTES (newdecl);
 
+  /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl
+    so that encode_section_info has a chance to look at the new decl
+    flags and attributes.  */
+  if (DECL_RTL_SET_P (olddecl) 
+      && (TREE_CODE (olddecl) == FUNCTION_DECL
+         || (TREE_CODE (olddecl) == VAR_DECL
+             && TREE_STATIC (olddecl))))
+    make_decl_rtl (olddecl, NULL);
+
   return 1;
 }
 
index d27ea229f5fb1e453db9b75cfd5af27c00162ece..db194e8b321f955561f30d58f8350a5bfe1d285a 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-21  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR c++/9738
+       * g++.dg/ext/dllimport2.C: New file.
+       * g++.dg/ext/dllimport3.C: New file.
+
 2003-05-20  Janis Johnson  <janis187@us.ibm.com>
 
        * gcc.dg/compat/struct-by-value-3_x.c: Move common pieces to headers.
diff --git a/gcc/testsuite/g++.dg/ext/dllimport2.C b/gcc/testsuite/g++.dg/ext/dllimport2.C
new file mode 100644 (file)
index 0000000..9564be4
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
+
+// PR 9738  Dllimport attribute is overriden by later definition
+
+void __attribute__((dllimport)) Bar(void);
+ void Foo(void)
+ {
+     Bar();
+ }
+ void Bar(void)
+ {
+ }
diff --git a/gcc/testsuite/g++.dg/ext/dllimport3.C b/gcc/testsuite/g++.dg/ext/dllimport3.C
new file mode 100644 (file)
index 0000000..d5e7955
--- /dev/null
@@ -0,0 +1,25 @@
+// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} }
+
+// PR 10148  Dllimport attribute of object is overriden by later
+// redefinition without attribute.
+struct Foo
+ {
+     int a;
+ };
+
+ __attribute__((dllimport)) struct Foo f;
+
+ void Bar(void)
+ {
+     void* dummy = &f;
+ }
+
+ struct Foo f;
+
+// Dllimport sets DECL_NON_ADDR_CONST_P to 1, so following
+// assignment would require static_initialization_and_destruction
+// if attribute is retained. 
+
+ void* dummy = &f;