1 2002-08-06 Aldy Hernandez <aldyh@redhat.com>
3 * c-decl.c (duplicate_decls): Error out for incompatible TLS
6 * testsuite/gcc.dg/tls/diag-3.c: New.
8 *** gcc/c-decl.c 1 Aug 2002 06:20:30 -0000 1.344
9 --- gcc/c-decl.c 7 Aug 2002 01:01:55 -0000
10 *************** duplicate_decls (newdecl, olddecl, diffe
13 if (TREE_CODE (newdecl) == VAR_DECL)
14 DECL_INITIAL (newdecl) = 0;
16 + /* TLS cannot follow non-TLS declaration. */
17 + else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
18 + && !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl))
20 + error_with_decl (newdecl, "thread-local declaration of `%s' follows non thread-local declaration");
21 + error_with_decl (olddecl, "previous declaration of `%s'");
23 + /* non-TLS declaration cannot follow TLS declaration. */
24 + else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
25 + && DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl))
27 + error_with_decl (newdecl, "non thread-local declaration of `%s' follows thread-local declaration");
28 + error_with_decl (olddecl, "previous declaration of `%s'");
32 errmsg = redeclaration_error_message (newdecl, olddecl);
33 *** gcc/testsuite/gcc.dg/tls/diag-3.c 1 Jan 1970 00:00:00 -0000
34 --- gcc/testsuite/gcc.dg/tls/diag-3.c 7 Aug 2002 01:01:55 -0000
38 + /* Report invalid extern and __thread combinations. */
40 + extern int j; /* { dg-error "previous declaration" } */
41 + __thread int j; /* { dg-error "thread-local declaration" } */
43 + extern __thread int i; /* { dg-error "previous declaration" } */
44 + int i; /* { dg-error "non thread-local" } */
46 + extern __thread int k; /* This is fine. */