summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/tls
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/tls
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/tls')
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-1.C31
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-2.C26
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-3.C11
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-4.C10
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-5.C5
-rw-r--r--gcc/testsuite/g++.dg/tls/init-1.C14
-rw-r--r--gcc/testsuite/g++.dg/tls/init-2.C14
-rw-r--r--gcc/testsuite/g++.dg/tls/static-1.C30
-rw-r--r--gcc/testsuite/g++.dg/tls/static-1a.cc20
-rw-r--r--gcc/testsuite/g++.dg/tls/tls.exp35
-rw-r--r--gcc/testsuite/g++.dg/tls/trivial.C3
11 files changed, 199 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/tls/diag-1.C b/gcc/testsuite/g++.dg/tls/diag-1.C
new file mode 100644
index 000000000..af538719d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-1.C
@@ -0,0 +1,31 @@
+// Valid __thread specifiers.
+// { dg-require-effective-target tls }
+
+__thread int g1;
+extern __thread int g2;
+static __thread int g3;
+
+void foo()
+{
+ extern __thread int l1;
+ static __thread int l2;
+}
+
+struct A {
+ static __thread int i;
+};
+
+__thread int A::i = 42;
+
+template <typename T> struct B {
+ static __thread T t;
+};
+
+template <typename T>
+__thread T B<T>::t = 42;
+
+void bar ()
+{
+ int j = B<int>::t;
+ int k = B<const int>::t;
+}
diff --git a/gcc/testsuite/g++.dg/tls/diag-2.C b/gcc/testsuite/g++.dg/tls/diag-2.C
new file mode 100644
index 000000000..484b18845
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-2.C
@@ -0,0 +1,26 @@
+/* Invalid __thread specifiers. */
+/* { dg-require-effective-target tls } */
+
+__thread extern int g1; /* { dg-error "'__thread' before 'extern'" } */
+__thread static int g2; /* { dg-error "'__thread' before 'static'" } */
+__thread __thread int g3; /* { dg-error "duplicate '__thread'" } */
+typedef __thread int g4; /* { dg-error "multiple storage classes" } */
+
+void foo()
+{
+ __thread int l1; /* { dg-error "implicitly auto and declared '__thread'" } */
+ auto __thread int l2; /* { dg-error "multiple storage classes" } */
+ __thread extern int l3; /* { dg-error "'__thread' before 'extern'" } */
+ register __thread int l4; /* { dg-error "multiple storage classes" } */
+}
+
+__thread void f1 (); /* { dg-error "invalid for function" } */
+extern __thread void f2 (); /* { dg-error "invalid for function" } */
+static __thread void f3 (); /* { dg-error "invalid for function" } */
+__thread void f4 () { } /* { dg-error "invalid for function" } */
+
+void bar(__thread int p1); /* { dg-error "(invalid in parameter)|(specified for parameter)" } */
+
+struct A {
+ __thread int i; /* { dg-error "storage class specified" } */
+};
diff --git a/gcc/testsuite/g++.dg/tls/diag-3.C b/gcc/testsuite/g++.dg/tls/diag-3.C
new file mode 100644
index 000000000..ea5158b89
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-3.C
@@ -0,0 +1,11 @@
+// Report invalid extern and __thread combinations.
+// { dg-require-effective-target tls }
+
+extern int j; // { dg-error "previously declared here" }
+__thread int j; // { dg-error "follows non-thread-local" }
+
+extern __thread int i; // { dg-error "previously declared here" }
+int i; // { dg-error "follows thread-local" }
+
+extern __thread int k; // This is fine.
+__thread int k;
diff --git a/gcc/testsuite/g++.dg/tls/diag-4.C b/gcc/testsuite/g++.dg/tls/diag-4.C
new file mode 100644
index 000000000..55e985e92
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-4.C
@@ -0,0 +1,10 @@
+/* Invalid __thread specifiers. */
+/* { dg-require-effective-target tls } */
+
+__thread typedef int g4; /* { dg-error "multiple storage classes" } */
+
+void foo()
+{
+ __thread auto int l2; /* { dg-error "multiple storage classes" } */
+ __thread register int l4; /* { dg-error "multiple storage classes" } */
+}
diff --git a/gcc/testsuite/g++.dg/tls/diag-5.C b/gcc/testsuite/g++.dg/tls/diag-5.C
new file mode 100644
index 000000000..ca92b3074
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-5.C
@@ -0,0 +1,5 @@
+// PR c++/30536
+// Invalid __thread specifiers.
+// { dg-require-effective-target tls }
+
+struct A { __thread register int i; }; // { dg-error "multiple storage classes|storage class specified" }
diff --git a/gcc/testsuite/g++.dg/tls/init-1.C b/gcc/testsuite/g++.dg/tls/init-1.C
new file mode 100644
index 000000000..97867123a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/init-1.C
@@ -0,0 +1,14 @@
+/* Valid initializations. */
+/* { dg-require-effective-target tls } */
+
+__thread int i = 42;
+
+static int j;
+__thread int *p = &j;
+
+/* Note that this is valid in C++ (unlike C) as a run-time initialization. */
+int *q = &i;
+
+/* Valid because "const int k" is an integral constant expression in C++. */
+__thread const int k = 42;
+__thread const int l = k;
diff --git a/gcc/testsuite/g++.dg/tls/init-2.C b/gcc/testsuite/g++.dg/tls/init-2.C
new file mode 100644
index 000000000..c9f646d3a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/init-2.C
@@ -0,0 +1,14 @@
+/* Invalid initializations. */
+/* { dg-require-effective-target tls } */
+
+extern __thread int i;
+__thread int *p = &i; /* { dg-error "dynamically initialized" } */
+
+extern int f();
+__thread int j = f(); /* { dg-error "dynamically initialized" } */
+
+struct S
+{
+ S();
+};
+__thread S s; /* { dg-error "" } two errors here */
diff --git a/gcc/testsuite/g++.dg/tls/static-1.C b/gcc/testsuite/g++.dg/tls/static-1.C
new file mode 100644
index 000000000..506b0fcf7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/static-1.C
@@ -0,0 +1,30 @@
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-require-effective-target tls_runtime }
+// { dg-add-options tls }
+// { dg-additional-sources "static-1a.cc" }
+
+extern "C" void abort ();
+extern int test ();
+
+struct A
+{
+ static __thread int i;
+};
+
+__thread int A::i = 8;
+
+int
+main ()
+{
+ if (A::i != 8)
+ abort ();
+
+ if (test ())
+ abort ();
+
+ if (A::i != 17)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/tls/static-1a.cc b/gcc/testsuite/g++.dg/tls/static-1a.cc
new file mode 100644
index 000000000..1c6109f86
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/static-1a.cc
@@ -0,0 +1,20 @@
+// { dg-do run }
+// { dg-options "-O2" }
+// { dg-require-effective-target tls_runtime }
+// { dg-add-options tls }
+// { dg-additional-sources "static-1a.cc" }
+
+struct A
+{
+ static __thread int i;
+};
+
+int
+test ()
+{
+ if (A::i != 8)
+ return 1;
+
+ A::i = 17;
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/tls/tls.exp b/gcc/testsuite/g++.dg/tls/tls.exp
new file mode 100644
index 000000000..6450ea34f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/tls.exp
@@ -0,0 +1,35 @@
+# Copyright (C) 2002, 2005, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CXXFLAGS
+if ![info exists DEFAULT_CXXFLAGS] then {
+ set DEFAULT_CXXFLAGS " -ansi -pedantic-errors -Wno-long-long"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" $DEFAULT_CXXFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/g++.dg/tls/trivial.C b/gcc/testsuite/g++.dg/tls/trivial.C
new file mode 100644
index 000000000..e2b8f45b8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/trivial.C
@@ -0,0 +1,3 @@
+// { dg-require-effective-target tls }
+
+__thread int i;