This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: PR 66655: Use COFF/PE weak symbols
- From: Nick Clifton <nickc at redhat dot com>
- To: Jeff Law <law at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 7 Jan 2016 12:15:27 +0000
- Subject: Re: RFA: PR 66655: Use COFF/PE weak symbols
- Authentication-results: sourceware.org; auth=none
- References: <87si2uss7r dot fsf at redhat dot com> <56876033 dot 8010107 at redhat dot com> <568BA318 dot 2020100 at redhat dot com> <568C149D dot 6050602 at redhat dot com>
Hi Jeff,
The attached patch adds the test derived from the BZ. There is one
small problem - I could not find a way to stop the additional source
file from being compiled as a test on its own.
I think for C++ code it's usually worked around by naming the
additional-source file with ".cc" rather than .C. Can you give that a
quick whirl and see if that avoids having the additional file used as a
a test on its own?
Thanks - that worked. :-)
Revised test attached. OK to apply ?
Cheers
Nick
--- /dev/null 2016-01-07 09:30:14.144966933 +0000
+++ gcc/testsuite/g++.dg/pr66655.C 2016-01-07 12:13:15.757187619 +0000
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-additional-sources "pr66655_1.cc" } */
+
+#include "pr66655.h"
+
+extern "C" void abort (void);
+
+#define COOKIE 0xabcd0123
+
+int
+g (void)
+{
+ return COOKIE;
+}
+
+extern int f (void);
+
+int
+main (void)
+{
+ S::set(0);
+ if (f () != COOKIE)
+ abort ();
+ return 0;
+}
--- /dev/null 2016-01-07 09:30:14.144966933 +0000
+++ gcc/testsuite/g++.dg/pr66655_1.cc 2016-01-07 12:04:30.586623022 +0000
@@ -0,0 +1,14 @@
+#include "pr66655.h"
+
+extern int g (void);
+
+int S::i;
+
+int
+f (void)
+{
+ int ret = g ();
+
+ S::set (ret);
+ return ret;
+}
--- /dev/null 2016-01-07 09:30:14.144966933 +0000
+++ gcc/testsuite/g++.dg/pr66655.h 2016-01-05 10:41:45.629561622 +0000
@@ -0,0 +1,5 @@
+struct S
+{
+ static int i;
+ static void set (int ii) { i = -ii; }
+};