1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
2 
foo()3 void foo() {
4 }
5 
foobool(int argc)6 bool foobool(int argc) {
7   return argc;
8 }
9 
10 struct S1; // expected-note {{declared here}}
11 
12 template <class T, typename S, int N> // expected-note {{declared here}}
13 T tmain(T argc, S **argv) {
14   T i;
15   #pragma omp parallel for num_threads // expected-error {{expected '(' after 'num_threads'}}
16   for (i = 0; i < argc; ++i) foo();
17   #pragma omp parallel for num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
18   for (i = 0; i < argc; ++i) foo();
19   #pragma omp parallel for num_threads () // expected-error {{expected expression}}
20   for (i = 0; i < argc; ++i) foo();
21   #pragma omp parallel for num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
22   for (i = 0; i < argc; ++i) foo();
23   #pragma omp parallel for num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
24   for (i = 0; i < argc; ++i) foo();
25   #pragma omp parallel for num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
26   for (i = 0; i < argc; ++i) foo();
27   #pragma omp parallel for num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel for' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a positive integer value}}
28   for (i = 0; i < argc; ++i) foo();
29   #pragma omp parallel for num_threads (S) // expected-error {{'S' does not refer to a value}}
30   for (i = 0; i < argc; ++i) foo();
31   #pragma omp parallel for 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 *'}}
32   for (i = 0; i < argc; ++i) foo();
33   #pragma omp parallel for num_threads (argc)
34   for (i = 0; i < argc; ++i) foo();
35   #pragma omp parallel for num_threads (N) // expected-error {{argument to 'num_threads' clause must be a positive integer value}}
36   for (i = 0; i < argc; ++i) foo();
37 
38   return argc;
39 }
40 
main(int argc,char ** argv)41 int main(int argc, char **argv) {
42   int i;
43   #pragma omp parallel for num_threads // expected-error {{expected '(' after 'num_threads'}}
44   for (i = 0; i < argc; ++i) foo();
45   #pragma omp parallel for num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
46   for (i = 0; i < argc; ++i) foo();
47   #pragma omp parallel for num_threads () // expected-error {{expected expression}}
48   for (i = 0; i < argc; ++i) foo();
49   #pragma omp parallel for num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
50   for (i = 0; i < argc; ++i) foo();
51   #pragma omp parallel for num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel for' are ignored}}
52   for (i = 0; i < argc; ++i) foo();
53   #pragma omp parallel for num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
54   for (i = 0; i < argc; ++i) foo();
55   #pragma omp parallel for num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel for' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a positive integer value}}
56   for (i = 0; i < argc; ++i) foo();
57   #pragma omp parallel for num_threads (S1) // expected-error {{'S1' does not refer to a value}}
58   for (i = 0; i < argc; ++i) foo();
59   #pragma omp parallel for 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 *'}}
60   for (i = 0; i < argc; ++i) foo();
61   #pragma omp parallel for 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}}
62   for (i = 0; i < argc; ++i) foo();
63 
64   return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
65 }
66