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