aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2002-08-07 01:25:01 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2002-08-07 01:25:01 +0000
commit1ae0ccb63f419456bafa7fcf72e45ced13539cc3 (patch)
tree5395e46c6dff3ce9c96f522bef40b5d5e72ad935
parentf1a044c7da72e0e0a4895b7d2f53bbb4f62ba9d0 (diff)
downloadgcc-1ae0ccb63f419456bafa7fcf72e45ced13539cc3.zip
gcc-1ae0ccb63f419456bafa7fcf72e45ced13539cc3.tar.gz
gcc-1ae0ccb63f419456bafa7fcf72e45ced13539cc3.tar.bz2
c-decl.c (duplicate_decls): Error out for incompatible TLS declarations.
* c-decl.c (duplicate_decls): Error out for incompatible TLS declarations. * testsuite/gcc.dg/tls/diag-3.c: New. From-SVN: r56084
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-decl.c14
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tls/diag-3.c10
4 files changed, 35 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 23f8caa..3aa4333 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2002-08-06 Aldy Hernandez <aldyh@redhat.com>
+
+ * c-decl.c (duplicate_decls): Error out for incompatible TLS
+ declarations.
+
+ * testsuite/gcc.dg/tls/diag-3.c: New.
+
2002-08-06 Jason Merrill <jason@redhat.com>
* c-common.c (c_expand_expr) [STMT_EXPR]: If the last expression is
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index aed707d..4adbe69 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1400,6 +1400,20 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
}
error_with_decl (olddecl, "previous declaration of `%s'");
}
+ /* TLS cannot follow non-TLS declaration. */
+ else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
+ && !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl))
+ {
+ error_with_decl (newdecl, "thread-local declaration of `%s' follows non thread-local declaration");
+ error_with_decl (olddecl, "previous declaration of `%s'");
+ }
+ /* non-TLS declaration cannot follow TLS declaration. */
+ else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
+ && DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl))
+ {
+ error_with_decl (newdecl, "non thread-local declaration of `%s' follows thread-local declaration");
+ error_with_decl (olddecl, "previous declaration of `%s'");
+ }
else
{
errmsg = redeclaration_error_message (newdecl, olddecl);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0acf870..58171e0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-08-06 Aldy Hernandez <aldyh@redhat.com>
+
+ * testsuite/gcc.dg/tls/diag-3.c: New.
+
2002-08-07 Gabriel Dos Reis <gdr@nerim.net>
* g++.dg/README (Subdirectories): Document new subdir expr.
diff --git a/gcc/testsuite/gcc.dg/tls/diag-3.c b/gcc/testsuite/gcc.dg/tls/diag-3.c
new file mode 100644
index 0000000..c23b141
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tls/diag-3.c
@@ -0,0 +1,10 @@
+/* Report invalid extern and __thread combinations. */
+
+extern int j; /* { dg-error "previous declaration" } */
+__thread int j; /* { dg-error "thread-local declaration for" } */
+
+extern __thread int i; /* { dg-error "previous declaration" } */
+int i; /* { dg-error "non thread-local" } */
+
+extern __thread int k; /* This is fine. */
+__thread int k;