summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/selectany2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/ext/selectany2.C')
-rw-r--r--gcc/testsuite/g++.dg/ext/selectany2.C30
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ext/selectany2.C b/gcc/testsuite/g++.dg/ext/selectany2.C
new file mode 100644
index 000000000..278b32d2f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/selectany2.C
@@ -0,0 +1,30 @@
+// { dg-do compile { target i?86-pc-cygwin } }
+// { dg-do compile { target i?86-*-mingw* x86_64-*-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;
+}