1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2 
3 void foo() {
4 }
5 
6 bool foobool(int argc) {
7   return argc;
8 }
9 
10 struct S1; // expected-note {{declared here}}
11 
12 template <class T, class S> // expected-note {{declared here}}
13 int tmain(T argc, S **argv) {
14   #pragma omp taskloop grainsize // expected-error {{expected '(' after 'grainsize'}}
15   for (int i = 0; i < 10; ++i)
16     foo();
17   #pragma omp taskloop grainsize ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
18   for (int i = 0; i < 10; ++i)
19     foo();
20   #pragma omp taskloop grainsize () // expected-error {{expected expression}}
21   for (int i = 0; i < 10; ++i)
22     foo();
23   #pragma omp taskloop grainsize (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
24   for (int i = 0; i < 10; ++i)
25     foo();
26   #pragma omp taskloop grainsize (argc)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
27   for (int i = 0; i < 10; ++i)
28     foo();
29   #pragma omp taskloop grainsize (argc > 0 ? argv[1][0] : argv[2][argc])
30   for (int i = 0; i < 10; ++i)
31     foo();
32   #pragma omp taskloop grainsize (foobool(argc)), grainsize (true) // expected-error {{directive '#pragma omp taskloop' cannot contain more than one 'grainsize' clause}}
33   for (int i = 0; i < 10; ++i)
34     foo();
35   #pragma omp taskloop grainsize (S) // expected-error {{'S' does not refer to a value}}
36   for (int i = 0; i < 10; ++i)
37     foo();
38   #pragma omp taskloop grainsize (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
39   for (int i = 0; i < 10; ++i)
40     foo();
41   #pragma omp taskloop grainsize(0) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
42   for (int i = 0; i < 10; ++i)
43     foo();
44   #pragma omp taskloop grainsize(-1) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
45   for (int i = 0; i < 10; ++i)
46     foo();
47   #pragma omp taskloop grainsize(argc) num_tasks(argc) // expected-error {{'num_tasks' and 'grainsize' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'grainsize' clause is specified here}}
48   for (int i = 0; i < 10; ++i)
49     foo();
50 
51   return 0;
52 }
53 
54 int main(int argc, char **argv) {
55   #pragma omp taskloop grainsize // expected-error {{expected '(' after 'grainsize'}}
56   for (int i = 0; i < 10; ++i)
57     foo();
58   #pragma omp taskloop grainsize ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
59   for (int i = 0; i < 10; ++i)
60     foo();
61   #pragma omp taskloop grainsize () // expected-error {{expected expression}}
62   for (int i = 0; i < 10; ++i)
63     foo();
64   #pragma omp taskloop grainsize (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
65   for (int i = 0; i < 10; ++i)
66     foo();
67   #pragma omp taskloop grainsize (argc)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
68   for (int i = 0; i < 10; ++i)
69     foo();
70   #pragma omp taskloop grainsize (argc > 0 ? argv[1][0] : argv[2][argc])
71   for (int i = 0; i < 10; ++i)
72     foo();
73   #pragma omp taskloop grainsize (foobool(argc)), grainsize (true) // expected-error {{directive '#pragma omp taskloop' cannot contain more than one 'grainsize' clause}}
74   for (int i = 0; i < 10; ++i)
75     foo();
76   #pragma omp taskloop grainsize (S1) // expected-error {{'S1' does not refer to a value}}
77   for (int i = 0; i < 10; ++i)
78     foo();
79   #pragma omp taskloop grainsize (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
80   for (int i = 0; i < 10; ++i)
81     foo();
82   #pragma omp taskloop grainsize (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
83   for (int i = 0; i < 10; ++i)
84     foo();
85   #pragma omp taskloop grainsize(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
86   for (int i = 0; i < 10; ++i)
87     foo();
88   #pragma omp taskloop grainsize(0)  // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
89   for (int i = 0; i < 10; ++i)
90     foo();
91   #pragma omp taskloop grainsize(-1) // expected-error {{argument to 'grainsize' clause must be a strictly positive integer value}}
92   for (int i = 0; i < 10; ++i)
93     foo();
94   #pragma omp taskloop grainsize(argc) num_tasks(argc) // expected-error {{'num_tasks' and 'grainsize' clause are mutually exclusive and may not appear on the same directive}} expected-note {{'grainsize' clause is specified here}}
95   for (int i = 0; i < 10; ++i)
96     foo();
97 
98   return tmain(argc, argv);
99 }
100