1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
4
foo()5 void foo() {
6 }
7
8 #if __cplusplus >= 201103L
9 // expected-note@+2 4 {{declared here}}
10 #endif
foobool(int argc)11 bool foobool(int argc) {
12 return argc;
13 }
14
15 struct S1; // expected-note {{declared here}}
16
17 template <class T, typename S, int N, int ST> // expected-note {{declared here}}
tmain(T argc,S ** argv)18 T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
19 #pragma omp target
20 #pragma omp teams
21 #pragma omp distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
22 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
23 #pragma omp target
24 #pragma omp teams
25 #pragma omp distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
26 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
27 #pragma omp target
28 #pragma omp teams
29 #pragma omp distribute parallel for collapse () // expected-error {{expected expression}}
30 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
31 #pragma omp target
32 #pragma omp teams
33 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
34 // expected-error@+2 2 {{expression is not an integral constant expression}}
35 // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
36 #pragma omp distribute parallel for collapse (argc
37 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
38 #pragma omp target
39 #pragma omp teams
40 // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
41 #pragma omp distribute parallel for collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
42 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
43 #pragma omp target
44 #pragma omp teams
45 #pragma omp distribute parallel for collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
46 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
47 #pragma omp target
48 #pragma omp teams
49 #pragma omp distribute parallel for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
50 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp distribute parallel for', but found only 1}}
51 // expected-error@+8 2 {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}}
52 // expected-error@+7 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
53 // expected-error@+6 2 {{expression is not an integral constant expression}}
54 #if __cplusplus >= 201103L
55 // expected-note@+4 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
56 #endif
57 #pragma omp target
58 #pragma omp teams
59 #pragma omp distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
60 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
61 #pragma omp target
62 #pragma omp teams
63 #pragma omp distribute parallel for collapse (S) // expected-error {{'S' does not refer to a value}}
64 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
65 #if __cplusplus <= 199711L
66 // expected-error@+6 2 {{expression is not an integral constant expression}}
67 #else
68 // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
69 #endif
70 #pragma omp target
71 #pragma omp teams
72 #pragma omp distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
73 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
74 #pragma omp target
75 #pragma omp teams
76 #pragma omp distribute parallel for collapse (1)
77 for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
78 #pragma omp target
79 #pragma omp teams
80 #pragma omp distribute parallel for collapse (N) // expected-error {{argument to 'collapse' clause must be a strictly positive integer value}}
81 for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
82 #pragma omp target
83 #pragma omp teams
84 #pragma omp distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
85 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute parallel for'}}
86 return argc;
87 }
88
main(int argc,char ** argv)89 int main(int argc, char **argv) {
90 #pragma omp target
91 #pragma omp teams
92 #pragma omp distribute parallel for collapse // expected-error {{expected '(' after 'collapse'}}
93 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
94 #pragma omp target
95 #pragma omp teams
96 #pragma omp distribute parallel for collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
98 #pragma omp target
99 #pragma omp teams
100 #pragma omp distribute parallel for collapse () // expected-error {{expected expression}}
101 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
102 #pragma omp target
103 #pragma omp teams
104 #pragma omp distribute parallel for collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
105 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute parallel for', but found only 1}}
106 #pragma omp target
107 #pragma omp teams
108 #pragma omp distribute parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}}
109 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute parallel for', but found only 1}}
110 // expected-error@+6 {{expression is not an integral constant expression}}
111 #if __cplusplus >= 201103L
112 // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
113 #endif
114 #pragma omp target
115 #pragma omp teams
116 #pragma omp distribute parallel for collapse (foobool(1) > 0 ? 1 : 2)
117 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
118 // expected-error@+8 {{expression is not an integral constant expression}}
119 #if __cplusplus >= 201103L
120 // expected-note@+6{{non-constexpr function 'foobool' cannot be used in a constant expression}}
121 #endif
122 // expected-error@+4 2 {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}}
123 // expected-error@+3 2 {{argument to 'collapse' clause must be a strictly positive integer value}}
124 #pragma omp target
125 #pragma omp teams
126 #pragma omp distribute parallel for collapse (foobool(argc)), collapse (true), collapse (-5)
127 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
128 #pragma omp target
129 #pragma omp teams
130 #pragma omp distribute parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}}
131 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
132 #if __cplusplus <= 199711L
133 // expected-error@+6 {{expression is not an integral constant expression}}
134 #else
135 // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}}
136 #endif
137 #pragma omp target
138 #pragma omp teams
139 #pragma omp distribute parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
140 for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
141 // expected-error@+5 {{statement after '#pragma omp distribute parallel for' must be a for loop}}
142 // expected-note@+3 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
143 #pragma omp target
144 #pragma omp teams
145 #pragma omp distribute parallel for collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
146 foo();
147 #pragma omp target
148 #pragma omp teams
149 #pragma omp distribute parallel for collapse (2) // expected-note {{as specified in 'collapse' clause}}
150 foo(); // expected-error {{expected 2 for loops after '#pragma omp distribute parallel for'}}
151 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
152 return tmain<int, char, 1, 0>(argc, argv);
153 }
154
155