Commit 1ae0ccb6 by Aldy Hernandez Committed by Aldy Hernandez

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
parent f1a044c7
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
......
......@@ -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);
......
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.
......
/* 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment