annotate clang/test/Sema/thread-specifier.c @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -DGNU
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DGNU -std=c++98
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic %s -std=c11 -DC11 -D__thread=_Thread_local
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify=expected,thread-local -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++98
anatofuz
parents:
diff changeset
5 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify -pedantic -x c++ %s -DCXX11 -D__thread=thread_local -std=c++11 -Wno-deprecated
anatofuz
parents:
diff changeset
6 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify=expected,thread-local -pedantic -x c++ %s -DC11 -D__thread=_Thread_local -std=c++11 -Wno-deprecated
anatofuz
parents:
diff changeset
7 // RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -Wno-private-extern -verify=expected,thread-local -pedantic %s -std=c99 -D__thread=_Thread_local -DC99
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 __thread int t1; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
10 __thread extern int t2; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
11 __thread static int t3; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
12 #ifdef GNU
anatofuz
parents:
diff changeset
13 // expected-warning@-3 {{'__thread' before 'extern'}}
anatofuz
parents:
diff changeset
14 // expected-warning@-3 {{'__thread' before 'static'}}
anatofuz
parents:
diff changeset
15 #endif
anatofuz
parents:
diff changeset
16
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
17 __private_extern__ __thread int t4; // thread-local-warning {{'_Thread_local' is a C11 extension}}
150
anatofuz
parents:
diff changeset
18 struct t5 { __thread int x; }; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
19 #ifdef __cplusplus
anatofuz
parents:
diff changeset
20 // expected-error-re@-2 {{'{{__thread|_Thread_local|thread_local}}' is only allowed on variable declarations}}
anatofuz
parents:
diff changeset
21 #else
anatofuz
parents:
diff changeset
22 // FIXME: The 'is only allowed on variable declarations' diagnostic is better here.
anatofuz
parents:
diff changeset
23 // expected-error@-5 {{type name does not allow storage class to be specified}}
anatofuz
parents:
diff changeset
24 #endif
anatofuz
parents:
diff changeset
25
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
26 __thread int t6(void); // thread-local-warning {{'_Thread_local' is a C11 extension}}
150
anatofuz
parents:
diff changeset
27 #if defined(GNU)
anatofuz
parents:
diff changeset
28 // expected-error@-2 {{'__thread' is only allowed on variable declarations}}
anatofuz
parents:
diff changeset
29 #elif defined(C11) || defined(C99)
anatofuz
parents:
diff changeset
30 // expected-error@-4 {{'_Thread_local' is only allowed on variable declarations}}
anatofuz
parents:
diff changeset
31 #else
anatofuz
parents:
diff changeset
32 // expected-error@-6 {{'thread_local' is only allowed on variable declarations}}
anatofuz
parents:
diff changeset
33 #endif
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 int f(__thread int t7) { // expected-error {{' is only allowed on variable declarations}} \
anatofuz
parents:
diff changeset
36 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
37 __thread int t8; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
38 #if defined(GNU)
anatofuz
parents:
diff changeset
39 // expected-error@-2 {{'__thread' variables must have global storage}}
anatofuz
parents:
diff changeset
40 #elif defined(C11) || defined(C99)
anatofuz
parents:
diff changeset
41 // expected-error@-4 {{'_Thread_local' variables must have global storage}}
anatofuz
parents:
diff changeset
42 #endif
anatofuz
parents:
diff changeset
43 extern __thread int t9; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
44 static __thread int t10; // thread-local-warning {{'_Thread_local' is a C11 extension}}
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
45 __private_extern__ __thread int t11; // thread-local-warning {{'_Thread_local' is a C11 extension}}
150
anatofuz
parents:
diff changeset
46 #if __cplusplus < 201103L
anatofuz
parents:
diff changeset
47 __thread auto int t12a; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local}}' declaration specifier}} \
anatofuz
parents:
diff changeset
48 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
49 auto __thread int t12b; // expected-error {{cannot combine with previous 'auto' declaration specifier}} \
anatofuz
parents:
diff changeset
50 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
51 #elif !defined(CXX11)
anatofuz
parents:
diff changeset
52 __thread auto t12a = 0; // expected-error {{'_Thread_local' variables must have global storage}} \
anatofuz
parents:
diff changeset
53 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
54 auto __thread t12b = 0; // expected-error {{'_Thread_local' variables must have global storage}} \
anatofuz
parents:
diff changeset
55 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
56 #endif
anatofuz
parents:
diff changeset
57 __thread register int t13a; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}} \
anatofuz
parents:
diff changeset
58 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
59 register __thread int t13b; // expected-error {{cannot combine with previous 'register' declaration specifier}} \
anatofuz
parents:
diff changeset
60 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
61 }
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 __thread typedef int t14; // expected-error-re {{cannot combine with previous '{{__thread|_Thread_local|thread_local}}' declaration specifier}} \
anatofuz
parents:
diff changeset
64 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
65 __thread int t15; // expected-note {{previous definition is here}} \
anatofuz
parents:
diff changeset
66 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
67 extern int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
anatofuz
parents:
diff changeset
68 extern int t16; // expected-note {{previous declaration is here}}
anatofuz
parents:
diff changeset
69 __thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}} \
anatofuz
parents:
diff changeset
70 // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 #ifdef CXX11
anatofuz
parents:
diff changeset
73 extern thread_local int t17; // expected-note {{previous declaration is here}}
anatofuz
parents:
diff changeset
74 _Thread_local int t17; // expected-error {{thread-local declaration of 't17' with static initialization follows declaration with dynamic initialization}} \
anatofuz
parents:
diff changeset
75 // expected-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
76 extern _Thread_local int t18; // expected-note {{previous declaration is here}} \
anatofuz
parents:
diff changeset
77 // expected-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
78 thread_local int t18; // expected-error {{thread-local declaration of 't18' with dynamic initialization follows declaration with static initialization}}
anatofuz
parents:
diff changeset
79 #endif
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 // PR13720
anatofuz
parents:
diff changeset
82 __thread int thread_int; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
83 int *thread_int_ptr = &thread_int;
anatofuz
parents:
diff changeset
84 #ifndef __cplusplus
anatofuz
parents:
diff changeset
85 // expected-error@-2 {{initializer element is not a compile-time constant}}
anatofuz
parents:
diff changeset
86 #endif
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
87 void g(void) {
150
anatofuz
parents:
diff changeset
88 int *p = &thread_int; // This is perfectly fine, though.
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90 #if __cplusplus >= 201103L
anatofuz
parents:
diff changeset
91 constexpr int *thread_int_ptr_2 = &thread_int; // expected-error {{must be initialized by a constant expression}}
anatofuz
parents:
diff changeset
92 #endif
anatofuz
parents:
diff changeset
93
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
94 int non_const(void);
150
anatofuz
parents:
diff changeset
95 __thread int non_const_init = non_const(); // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
96 #if !defined(__cplusplus)
anatofuz
parents:
diff changeset
97 // expected-error@-2 {{initializer element is not a compile-time constant}}
anatofuz
parents:
diff changeset
98 #elif !defined(CXX11)
anatofuz
parents:
diff changeset
99 // expected-error@-4 {{initializer for thread-local variable must be a constant expression}}
anatofuz
parents:
diff changeset
100 #if __cplusplus >= 201103L
anatofuz
parents:
diff changeset
101 // expected-note@-6 {{use 'thread_local' to allow this}}
anatofuz
parents:
diff changeset
102 #endif
anatofuz
parents:
diff changeset
103 #endif
anatofuz
parents:
diff changeset
104
anatofuz
parents:
diff changeset
105 #ifdef __cplusplus
anatofuz
parents:
diff changeset
106 struct S {
anatofuz
parents:
diff changeset
107 ~S();
anatofuz
parents:
diff changeset
108 };
anatofuz
parents:
diff changeset
109 __thread S s; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
110 #if !defined(CXX11)
anatofuz
parents:
diff changeset
111 // expected-error@-2 {{type of thread-local variable has non-trivial destruction}}
anatofuz
parents:
diff changeset
112 #if __cplusplus >= 201103L
anatofuz
parents:
diff changeset
113 // expected-note@-4 {{use 'thread_local' to allow this}}
anatofuz
parents:
diff changeset
114 #endif
anatofuz
parents:
diff changeset
115 #endif
anatofuz
parents:
diff changeset
116 #endif
anatofuz
parents:
diff changeset
117
anatofuz
parents:
diff changeset
118 #ifdef __cplusplus
anatofuz
parents:
diff changeset
119 struct HasCtor {
anatofuz
parents:
diff changeset
120 HasCtor();
anatofuz
parents:
diff changeset
121 };
anatofuz
parents:
diff changeset
122 __thread HasCtor var_with_ctor; // thread-local-warning {{'_Thread_local' is a C11 extension}}
anatofuz
parents:
diff changeset
123 #if !defined(CXX11)
anatofuz
parents:
diff changeset
124 // expected-error@-2 {{initializer for thread-local variable must be a constant expression}}
anatofuz
parents:
diff changeset
125 #if __cplusplus >= 201103L
anatofuz
parents:
diff changeset
126 // expected-note@-4 {{use 'thread_local' to allow this}}
anatofuz
parents:
diff changeset
127 #endif
anatofuz
parents:
diff changeset
128 #endif
anatofuz
parents:
diff changeset
129 #endif
anatofuz
parents:
diff changeset
130
anatofuz
parents:
diff changeset
131 __thread int aggregate[10] = {0}; // thread-local-warning {{'_Thread_local' is a C11 extension}}