aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorRichard Henderson <rth@gcc.gnu.org>2002-05-22 16:42:57 -0700
committerRichard Henderson <rth@gcc.gnu.org>2002-05-22 16:42:57 -0700
commit7a1f3f5f3bdf7862391b3404eaaf348364ba57bd (patch)
treecb01828f5937f4aad110232990db6d0285400a54 /gcc/testsuite
parentc711ba8e2edb69d3f6fa58cfba1d6dc49847afcd (diff)
downloadgcc-7a1f3f5f3bdf7862391b3404eaaf348364ba57bd.zip
gcc-7a1f3f5f3bdf7862391b3404eaaf348364ba57bd.tar.gz
gcc-7a1f3f5f3bdf7862391b3404eaaf348364ba57bd.tar.bz2
decl.c (check_tag_decl): Handle RID_THREAD.
* decl.c (check_tag_decl): Handle RID_THREAD. (obscure_complex_init): Reject run-time init of tls. (grokvardecl, grokdeclarator): Handle RID_THREAD. * lex.c (reswords): Add __thread. (rid_to_yy): Map RID_THREAD to SCSPEC. * g++.dg/dg.exp: Prune the tls subdirectory. * g++.dg/tls/tls.exp, g++.dg/tls/trivial.C: New. * g++.dg/tls/diag-1.C, g++.dg/tls/diag-2.C: New. * g++.dg/tls/init-1.C: New. From-SVN: r53754
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog21
-rw-r--r--gcc/testsuite/g++.dg/dg.exp9
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-1.C30
-rw-r--r--gcc/testsuite/g++.dg/tls/diag-2.C25
-rw-r--r--gcc/testsuite/g++.dg/tls/init-1.C13
-rw-r--r--gcc/testsuite/g++.dg/tls/init-2.C13
-rw-r--r--gcc/testsuite/g++.dg/tls/tls.exp44
-rw-r--r--gcc/testsuite/g++.dg/tls/trivial.C1
8 files changed, 145 insertions, 11 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index eb45471..9807295 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2002-05-22 Richard Henderson <rth@redhat.com>
+
+ * g++.dg/dg.exp: Prune the tls subdirectory.
+ * g++.dg/tls/tls.exp, g++.dg/tls/trivial.C: New.
+ * g++.dg/tls/diag-1.C, g++.dg/tls/diag-2.C: New.
+ * g++.dg/tls/init-1.C: New.
+
2002-05-22 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/20020517-1.c: New test.
@@ -168,11 +175,11 @@ Mon May 20 10:51:35 2002 J"orn Rennecke <joern.rennecke@superh.com>
2002-05-02 Aldy Hernandez <aldyh@redhat.com>
- * gcc.dg/altivec-8.c: New.
+ * gcc.dg/altivec-8.c: New.
2002-05-01 Aldy Hernandez <aldyh@redhat.com>
- * gcc.dg/altivec-7.c: New.
+ * gcc.dg/altivec-7.c: New.
2002-04-29 Jakub Jelinek <jakub@redhat.com>
@@ -319,8 +326,8 @@ Wed Apr 24 21:38:36 2002 J"orn Rennecke <joern.rennecke@superh.com>
2002-04-18 Richard Henderson <rth@redhat.com>
- * gcc.dg/20000906-1.c: Enable for all targets.
- * gcc.c-torture/compile/iftrap-2.c: New.
+ * gcc.dg/20000906-1.c: Enable for all targets.
+ * gcc.c-torture/compile/iftrap-2.c: New.
2002-04-18 Jakub Jelinek <jakub@redhat.com>
@@ -329,9 +336,9 @@ Wed Apr 24 21:38:36 2002 J"orn Rennecke <joern.rennecke@superh.com>
2002-04-18 Richard Henderson <rth@redhat.com>
- * gcc.c-torture/compile/iftrap-1.c: New.
- * gcc.dg/iftrap-1.c: Adjust for ia64.
- * gcc.dg/iftrap-2.c: New.
+ * gcc.c-torture/compile/iftrap-1.c: New.
+ * gcc.dg/iftrap-1.c: Adjust for ia64.
+ * gcc.dg/iftrap-2.c: New.
2002-04-18 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp
index b59d302..da499be 100644
--- a/gcc/testsuite/g++.dg/dg.exp
+++ b/gcc/testsuite/g++.dg/dg.exp
@@ -31,10 +31,11 @@ dg-init
# Gather a list of all tests, with the exception of those in directories
# that are handled specially.
set all [lsort [find $srcdir/$subdir *.C]]
-set tests [prune [prune [prune [prune $all $srcdir/$subdir/special/*] \
- $srcdir/$subdir/debug/*] \
- $srcdir/$subdir/gcov/*] \
- $srcdir/$subdir/bprob/*]
+set tests [prune $tests $srcdir/$subdir/bprob/*]
+set tests [prune $tests $srcdir/$subdir/debug/*]
+set tests [prune $tests $srcdir/$subdir/gcov/*]
+set tests [prune $tests $srcdir/$subdir/special/*]
+set tests [prune $tests $srcdir/$subdir/tls/*]
# Main loop.
dg-runtest $tests "" $DEFAULT_CXXFLAGS
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 0000000..697d0b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-1.C
@@ -0,0 +1,30 @@
+/* Valid __thread specifiers. */
+
+__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 0000000..6365406
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/diag-2.C
@@ -0,0 +1,25 @@
+/* Invalid __thread specifiers. */
+
+__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 "specified for field" } */
+};
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 0000000..74f7641
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/init-1.C
@@ -0,0 +1,13 @@
+/* Valid initializations. */
+
+__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 0000000..49df501
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/init-2.C
@@ -0,0 +1,13 @@
+/* Invalid initializations. */
+
+extern __thread int i;
+__thread int *p = &i; /* { dg-error "run-time initialization" } */
+
+extern int f();
+__thread int j = f(); /* { dg-error "run-time initialization" } */
+
+struct S
+{
+ S();
+};
+__thread S s; /* { dg-error "run-time initialization" } */
diff --git a/gcc/testsuite/g++.dg/tls/tls.exp b/gcc/testsuite/g++.dg/tls/tls.exp
new file mode 100644
index 0000000..a00dad7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/tls.exp
@@ -0,0 +1,44 @@
+# Copyright (C) 2002 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 2 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# Test for thread-local data supported by the platform. If it
+# isn't, everything will fail with the "not supported" message.
+
+set comp_output [g++_target_compile \
+ "$srcdir/$subdir/trivial.C" "trivial.S" assembly ""]
+if { [string match "*not supported*" $comp_output] } {
+ return 0
+}
+
+# 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 0000000..1fd7063
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/trivial.C
@@ -0,0 +1 @@
+__thread int i;