Clang Project

clang_source_code/test/OpenMP/distribute_parallel_for_simd_num_threads_messages.cpp
1// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
3// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s
4
5void foo() {
6}
7
8bool foobool(int argc) {
9  return argc;
10}
11
12struct S1; // expected-note {{declared here}}
13
14template <class T, typename S, int N> // expected-note {{declared here}}
15T tmain(T argc, S **argv) {
16  T i;
17#pragma omp target
18#pragma omp teams
19#pragma omp distribute parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}}
20  for (i = 0; i < argc; ++i) foo();
21#pragma omp target
22#pragma omp teams
23#pragma omp distribute parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
24  for (i = 0; i < argc; ++i) foo();
25#pragma omp target
26#pragma omp teams
27#pragma omp distribute parallel for simd num_threads () // expected-error {{expected expression}}
28  for (i = 0; i < argc; ++i) foo();
29#pragma omp target
30#pragma omp teams
31#pragma omp distribute parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
32  for (i = 0; i < argc; ++i) foo();
33#pragma omp target
34#pragma omp teams
35#pragma omp distribute parallel for simd num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
36  for (i = 0; i < argc; ++i) foo();
37#pragma omp target
38#pragma omp teams
39#pragma omp distribute parallel for simd num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
40  for (i = 0; i < argc; ++i) foo();
41#pragma omp target
42#pragma omp teams
43#pragma omp distribute parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
44  for (i = 0; i < argc; ++i) foo();
45#pragma omp target
46#pragma omp teams
47#pragma omp distribute parallel for simd num_threads (S) // expected-error {{'S' does not refer to a value}}
48  for (i = 0; i < argc; ++i) foo();
49#pragma omp target
50#pragma omp teams
51#pragma omp distribute parallel for simd 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 *'}}
52  for (i = 0; i < argc; ++i) foo();
53#pragma omp target
54#pragma omp teams
55#pragma omp distribute parallel for simd num_threads (argc)
56  for (i = 0; i < argc; ++i) foo();
57#pragma omp target
58#pragma omp teams
59#pragma omp distribute parallel for simd num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
60  for (i = 0; i < argc; ++i) foo();
61
62  return argc;
63}
64
65int main(int argc, char **argv) {
66  int i;
67#pragma omp target
68#pragma omp teams
69#pragma omp distribute parallel for simd num_threads // expected-error {{expected '(' after 'num_threads'}}
70  for (i = 0; i < argc; ++i) foo();
71#pragma omp target
72#pragma omp teams
73#pragma omp distribute parallel for simd num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
74  for (i = 0; i < argc; ++i) foo();
75#pragma omp target
76#pragma omp teams
77#pragma omp distribute parallel for simd num_threads () // expected-error {{expected expression}}
78  for (i = 0; i < argc; ++i) foo();
79#pragma omp target
80#pragma omp teams
81#pragma omp distribute parallel for simd num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
82  for (i = 0; i < argc; ++i) foo();
83#pragma omp target
84#pragma omp teams
85#pragma omp distribute parallel for simd num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for simd' are ignored}}
86  for (i = 0; i < argc; ++i) foo();
87#pragma omp target
88#pragma omp teams
89#pragma omp distribute parallel for simd num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
90  for (i = 0; i < argc; ++i) foo();
91#pragma omp target
92#pragma omp teams
93#pragma omp distribute parallel for simd num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
94  for (i = 0; i < argc; ++i) foo();
95#pragma omp target
96#pragma omp teams
97#pragma omp distribute parallel for simd num_threads (S1) // expected-error {{'S1' does not refer to a value}}
98  for (i = 0; i < argc; ++i) foo();
99#pragma omp target
100#pragma omp teams
101#pragma omp distribute parallel for simd 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 *'}}
102  for (i = 0; i < argc; ++i) foo();
103#pragma omp target
104#pragma omp teams
105#pragma omp distribute parallel for simd 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}}
106  for (i = 0; i < argc; ++i) foo();
107
108  return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
109}
110