OSDN Git Service

* g++.dg/ext/selectany1.C: New file. Test for linkonce sections.
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Apr 2005 08:20:24 +0000 (08:20 +0000)
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Apr 2005 08:20:24 +0000 (08:20 +0000)
* g++.dg/ext/selectany2.C: New file. Test for errors with invalid
selectany usage.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97378 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/selectany1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/selectany2.C [new file with mode: 0644]

index a08f51c..2f5f466 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-01  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       * g++.dg/ext/selectany1.C: New file. Test for linkonce sections.
+       * g++.dg/ext/selectany2.C: New file. Test for errors with invalid
+       selectany usage.
+
 2005-04-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/19406
 2005-04-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/19406
diff --git a/gcc/testsuite/g++.dg/ext/selectany1.C b/gcc/testsuite/g++.dg/ext/selectany1.C
new file mode 100644 (file)
index 0000000..065332a
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile { target i?86-pc-cygwin } }
+// { dg-do compile { target i?86-pc-mingw* } }
+
+// Check that selectany attribute puts symbols into link-once sections.
+
+// { dg-final { scan-assembler "\.section\t\.data\\\$foo\[^\n\]*\n\t\.linkonce discard" } }
+// { dg-final { scan-assembler "\.section\t\.data\\\$x\[^\n\]*\n\t\.linkonce discard" } }
+// { dg-final { scan-assembler-dem "\nguard variable for x:" } }
+
+__declspec (selectany) int foo = 1;
+
+class X
+{
+private:
+  int m_i;
+public:
+  X(int i): m_i(i){}
+  ~X(){};
+};
+
+__declspec(selectany) X x(1);
diff --git a/gcc/testsuite/g++.dg/ext/selectany2.C b/gcc/testsuite/g++.dg/ext/selectany2.C
new file mode 100644 (file)
index 0000000..af70dcc
--- /dev/null
@@ -0,0 +1,30 @@
+// { dg-do compile { target i?86-pc-cygwin } }
+// { dg-do compile { target i?86-pc-mingw* } }
+
+// Check for errors with invalid usage of selectany attribute.
+
+extern int foo;
+__declspec (selectany) int foo = 1;  // OK
+
+struct d
+{
+  static int foo;
+};
+__declspec (selectany) int d::foo = 1;  // OK 
+
+struct  f
+{
+  int i;
+};
+__declspec (selectany) struct f  F= {1}; // OK
+
+__declspec (selectany) int boo;        //{ dg-error "selectany" }
+
+__declspec (selectany) static int bar = 1; // { dg-error "selectany" }
+int use_bar = bar;  //  Avoid defined but not used warning. 
+
+int baz()
+{
+  __declspec (selectany)  int foo = 1;  // { dg-error "selectany" }
+  return foo;
+}