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