critical_messages.cpp
6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
int foo();
void xxx(int argc) {
int x; // expected-note {{initialize the variable 'x' to silence this warning}}
#pragma omp critical
argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
}
template<typename T, int N>
int tmain(int argc, char **argv) { // expected-note {{declared here}}
#pragma omp critical
;
#pragma omp critical untied allocate(argc) // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}} expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp critical'}}
#pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}
#pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp critical (name1)
foo();
{
#pragma omp critical
} // expected-error {{expected statement}}
#pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}}
#pragma omp critical
for (int i = 0; i < 10; ++i) {
foo();
#pragma omp parallel
#pragma omp for
for (int j = 0; j < 10; j++) {
foo();
#pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}}
foo();
}
}
#pragma omp critical (name2)
#pragma omp critical
for (int i = 0; i < 10; ++i) {
foo();
#pragma omp parallel
#pragma omp for
for (int j = 0; j < 10; j++) {
#pragma omp critical
foo();
}
}
#pragma omp critical (name2)
#pragma omp critical
for (int i = 0; i < 10; ++i) {
foo();
#pragma omp parallel
#pragma omp for
for (int j = 0; j < 10; j++) {
#pragma omp critical (nam)
foo();
}
}
#pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}}
foo();
#pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note {{read of non-const variable 'argc' is not allowed in a constant expression}}
foo();
#pragma omp critical (name) hint(N) // expected-error {{argument to 'hint' clause must be a strictly positive integer value}} expected-error {{constructs with the same name must have a 'hint' clause with the same value}} expected-note {{'hint' clause with value '4'}}
foo();
#pragma omp critical hint(N) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}}
foo();
return 0;
}
int main(int argc, char **argv) { // expected-note {{declared here}}
#pragma omp critical
;
#pragma omp critical untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}}
#pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}
#pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp critical (name1)
foo();
{
#pragma omp critical
} // expected-error {{expected statement}}
#pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}}
#pragma omp critical
for (int i = 0; i < 10; ++i) {
foo();
#pragma omp parallel
#pragma omp for
for (int j = 0; j < 10; j++) {
foo();
#pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}}
foo();
}
}
#pragma omp critical (name2)
#pragma omp critical
for (int i = 0; i < 10; ++i) {
foo();
#pragma omp parallel
#pragma omp for
for (int j = 0; j < 10; j++) {
#pragma omp critical
foo();
}
}
#pragma omp critical (name2)
#pragma omp critical
for (int i = 0; i < 10; ++i) {
foo();
#pragma omp parallel
#pragma omp for
for (int j = 0; j < 10; j++) {
#pragma omp critical (nam)
foo();
}
}
#pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}}
foo();
#pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
foo();
#pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note {{read of non-const variable 'argc' is not allowed in a constant expression}}
foo();
#pragma omp critical (name) hint(23) // expected-note {{previous 'hint' clause with value '23'}}
foo();
#pragma omp critical hint(-5) // expected-error {{argument to 'hint' clause must be a strictly positive integer value}}
foo();
#pragma omp critical hint(1) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}}
foo();
return tmain<int, 4>(argc, argv) + tmain<float, -5>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<float, -5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
int foo() {
L1: // expected-note {{jump exits scope of OpenMP structured block}}
foo();
#pragma omp critical
{
foo();
goto L1; // expected-error {{cannot jump from this goto statement to its label}}
}
goto L2; // expected-error {{cannot jump from this goto statement to its label}}
#pragma omp critical
{ // expected-note {{jump bypasses OpenMP structured block}}
L2:
foo();
}
return 0;
}