Debian Codegraph @

clang/test/OpenMP/target_parallel_num_threads_messages.cpp

raw
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
3
4 // RUN: %clang_cc1 -DOMP60 -verify=expected,omp60 -fopenmp -fopenmp-version=60 -ferror-limit 100 %s -Wuninitialized
5 // RUN: %clang_cc1 -DOMP60 -verify=expected,omp60 -fopenmp-simd -fopenmp-version=60 -ferror-limit 100 %s -Wuninitialized
6
7 void foo() {
8 }
9
10 bool foobool(int argc) {
11 return argc;
12 }
13
14 struct S1; // expected-note {{declared here}} omp60-note {{declared here}}
15
16 #define redef_num_threads(a, b) num_threads(a)
17
18 template <class T, typename S, int N> // expected-note {{declared here}} omp60-note {{declared here}}
19 T tmain(T argc, S **argv) {
20 T z;
21 #pragma omp target parallel num_threads // expected-error {{expected '(' after 'num_threads'}}
22 foo();
23 #pragma omp target parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
24 foo();
25 #pragma omp target parallel num_threads () // expected-error {{expected expression}}
26 foo();
27 #pragma omp target parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
28 foo();
29 #pragma omp target parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}}
30 foo();
31 #pragma omp target parallel num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
32 foo();
33 #pragma omp target parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
34 foo();
35 #pragma omp target parallel num_threads (S) // expected-error {{'S' does not refer to a value}}
36 foo();
37 #pragma omp target parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
38 foo();
39 #pragma omp target parallel num_threads (argc + z)
40 foo();
41 #pragma omp target parallel num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
42 foo();
43 #pragma omp target parallel redef_num_threads (argc, argc)
44 foo();
45
46 #ifdef OMP60
47 // Valid uses of strict modifier
48 #pragma omp target parallel num_threads(strict: 4)
49 foo();
50 #pragma omp target parallel num_threads(strict: argc+z)
51 foo();
52
53 // Invalid: missing expression after strict:
54 #pragma omp target parallel num_threads(strict: ) // omp60-error {{expected expression}}
55 foo();
56 #pragma omp target parallel num_threads(strict:) // omp60-error {{expected expression}}
57 foo();
58 #pragma omp target parallel num_threads(strict: // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}
59 foo();
60
61 // Invalid: unknown/missing modifier
62 #pragma omp target parallel num_threads(foo: 4) // omp60-error {{expected 'strict' in OpenMP clause 'num_threads'}}
63 foo();
64 #pragma omp target parallel num_threads(: 4) // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}
65 foo();
66 #pragma omp target parallel num_threads(:)// omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}
67 foo();
68
69 // Invalid: missing colon after modifier
70 #pragma omp target parallel num_threads(strict 4) // omp60-error {{missing ':' after strict modifier}}
71 foo();
72
73 // Invalid: negative, zero, or non-integral
74 #pragma omp target parallel num_threads(strict: -1) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
75 foo();
76 #pragma omp target parallel num_threads(strict: 0) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
77 foo();
78 #pragma omp target parallel num_threads(strict: (argc > 0) ? argv[1] : argv[2]) // omp60-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
79 foo();
80 #pragma omp target parallel num_threads(strict: S) // omp60-error {{'S' does not refer to a value}}
81 foo();
82 #pragma omp target parallel num_threads(strict: argv[1]=2) // omp60-error {{expected ')'}} omp60-note {{to match this '('}} omp60-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
83 foo();
84 #pragma omp target parallel num_threads(strict: N) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
85 foo();
86
87 // Invalid: multiple strict modifiers or mixed with non-strict
88 #pragma omp target parallel num_threads(strict: 4, strict: 5) // omp60-error {{expected ')'}} expected-note {{to match this '('}}
89 foo();
90 #pragma omp target parallel num_threads(strict: 4), num_threads(5) // omp60-error {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}}
91 foo();
92 #pragma omp target parallel num_threads(4), num_threads(strict: 5) // omp60-error {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}}
93 foo();
94 #endif // OMP60
95
96 return argc;
97 }
98
99 int main(int argc, char **argv) {
100 int z;
101 #pragma omp target parallel num_threads // expected-error {{expected '(' after 'num_threads'}}
102 foo();
103 #pragma omp target parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
104 foo();
105 #pragma omp target parallel num_threads () // expected-error {{expected expression}}
106 foo();
107 #pragma omp target parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
108 foo();
109 #pragma omp target parallel num_threads (z + argc)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel' are ignored}}
110 foo();
111 #pragma omp target parallel num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
112 foo();
113 #pragma omp target parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
114 foo();
115 #pragma omp target parallel num_threads (S1) // expected-error {{'S1' does not refer to a value}}
116 foo();
117 #pragma omp target parallel num_threads (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
118 foo();
119 #pragma omp target parallel num_threads (num_threads(tmain<int, char, -1>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} expected-note {{in instantiation of function template specialization 'tmain<int, char, -1>' requested here}}
120 foo();
121 #pragma omp target parallel redef_num_threads (argc, argc)
122 foo();
123
124 #ifdef OMP60
125 // Valid uses of strict modifier
126 #pragma omp target parallel num_threads(strict: 4)
127 foo();
128 #pragma omp target parallel num_threads(strict: argc+z)
129 foo();
130
131 // Invalid: missing expression after strict:
132 #pragma omp target parallel num_threads(strict: ) // omp60-error {{expected expression}}
133 foo();
134 #pragma omp target parallel num_threads(strict:) // omp60-error {{expected expression}}
135 foo();
136 #pragma omp target parallel num_threads(strict: // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}
137 foo();
138
139 // Invalid: unknown/missing modifier
140 #pragma omp target parallel num_threads(foo: 4) // omp60-error {{expected 'strict' in OpenMP clause 'num_threads'}}
141 foo();
142 #pragma omp target parallel num_threads(: 4) // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}
143 foo();
144 #pragma omp target parallel num_threads(:) // omp60-error {{expected expression}} omp60-error {{expected ')'}} omp60-note {{to match this '('}}
145 foo();
146
147 // Invalid: missing colon after modifier
148 #pragma omp target parallel num_threads(strict 4) // omp60-error {{missing ':' after strict modifier}}
149 foo();
150
151 // Invalid: negative, zero, or non-integral
152 #pragma omp target parallel num_threads(strict: -1) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
153 foo();
154 #pragma omp target parallel num_threads(strict: 0) // omp60-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
155 foo();
156 #pragma omp target parallel num_threads(strict: (argc > 0) ? argv[1] : argv[2]) // omp60-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
157 foo();
158 #pragma omp target parallel num_threads(strict: S1) // omp60-error {{'S1' does not refer to a value}}
159 foo();
160 #pragma omp target parallel num_threads(strict: argv[1]=2) // omp60-error {{expected ')'}} omp60-note {{to match this '('}} omp60-error {{expression must have integral or unscoped enumeration type, not 'char *'}}
161 foo();
162
163 // Invalid: multiple strict modifiers or mixed with non-strict
164 #pragma omp target parallel num_threads(strict: 4, strict: 5) // omp60-error {{expected ')'}} expected-note {{to match this '('}}
165 foo();
166 #pragma omp target parallel num_threads(strict: 4), num_threads(5) // omp60-error {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}}
167 foo();
168 #pragma omp target parallel num_threads(4), num_threads(strict: 5) // omp60-error {{directive '#pragma omp target parallel' cannot contain more than one 'num_threads' clause}}
169 foo();
170 #endif // OMP60
171
172 return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
173 }