1*a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
2568a833fSAlexey Bataev 
3*a914888bSAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
4a8a9153aSAlexey Bataev 
foo()5568a833fSAlexey Bataev void foo() {
6568a833fSAlexey Bataev }
7568a833fSAlexey Bataev 
foobool(int argc)8568a833fSAlexey Bataev bool foobool(int argc) {
9568a833fSAlexey Bataev   return argc;
10568a833fSAlexey Bataev }
11568a833fSAlexey Bataev 
12568a833fSAlexey Bataev struct S1; // expected-note {{declared here}}
13568a833fSAlexey Bataev 
14c8956797SAlexey Bataev #define redef_num_threads(a, b) num_threads(a)
15c8956797SAlexey Bataev 
16568a833fSAlexey Bataev template <class T, typename S, int N> // expected-note {{declared here}}
tmain(T argc,S ** argv)17568a833fSAlexey Bataev T tmain(T argc, S **argv) {
18*a914888bSAlexey Bataev   T z;
19568a833fSAlexey Bataev   #pragma omp parallel num_threads // expected-error {{expected '(' after 'num_threads'}}
20568a833fSAlexey Bataev   #pragma omp parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
21568a833fSAlexey Bataev   #pragma omp parallel num_threads () // expected-error {{expected expression}}
22568a833fSAlexey Bataev   #pragma omp parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
23568a833fSAlexey Bataev   #pragma omp parallel num_threads (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
24568a833fSAlexey Bataev   #pragma omp parallel num_threads ((argc > 0) ? argv[1] : argv[2]) // expected-error 2 {{expression must have integral or unscoped enumeration type, not 'char *'}}
25a056935aSAlexey Bataev   #pragma omp parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
26568a833fSAlexey Bataev   #pragma omp parallel num_threads (S) // expected-error {{'S' does not refer to a value}}
27568a833fSAlexey Bataev   #pragma omp 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 *'}}
28*a914888bSAlexey Bataev   #pragma omp parallel num_threads (argc+z)
29a056935aSAlexey Bataev   #pragma omp parallel num_threads (N) // expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
30c8956797SAlexey Bataev   #pragma omp parallel redef_num_threads (argc, argc)
31568a833fSAlexey Bataev   foo();
32568a833fSAlexey Bataev 
33568a833fSAlexey Bataev   return argc;
34568a833fSAlexey Bataev }
35568a833fSAlexey Bataev 
main(int argc,char ** argv)36568a833fSAlexey Bataev int main(int argc, char **argv) {
37*a914888bSAlexey Bataev int z;
38568a833fSAlexey Bataev   #pragma omp parallel num_threads // expected-error {{expected '(' after 'num_threads'}}
39568a833fSAlexey Bataev   #pragma omp parallel num_threads ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
40568a833fSAlexey Bataev   #pragma omp parallel num_threads () // expected-error {{expected expression}}
41568a833fSAlexey Bataev   #pragma omp parallel num_threads (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
42*a914888bSAlexey Bataev   #pragma omp parallel num_threads (z+argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
43568a833fSAlexey Bataev   #pragma omp parallel num_threads (argc > 0 ? argv[1] : argv[2]) // expected-error {{integral }}
44a056935aSAlexey Bataev   #pragma omp parallel num_threads (foobool(argc)), num_threads (true), num_threads (-5) // expected-error 2 {{directive '#pragma omp parallel' cannot contain more than one 'num_threads' clause}} expected-error {{argument to 'num_threads' clause must be a strictly positive integer value}}
45568a833fSAlexey Bataev   #pragma omp parallel num_threads (S1) // expected-error {{'S1' does not refer to a value}}
46568a833fSAlexey Bataev   #pragma omp 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 *'}}
47568a833fSAlexey Bataev   #pragma omp 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}}
48c8956797SAlexey Bataev   #pragma omp parallel redef_num_threads (argc, argc)
49568a833fSAlexey Bataev   foo();
50568a833fSAlexey Bataev 
51568a833fSAlexey Bataev   return tmain<int, char, 3>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 3>' requested here}}
52568a833fSAlexey Bataev }
53