1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2*0a6a1f1dSLionel Sambuc
foo()3*0a6a1f1dSLionel Sambuc void foo() {
4*0a6a1f1dSLionel Sambuc }
5*0a6a1f1dSLionel Sambuc
foobool(int argc)6*0a6a1f1dSLionel Sambuc bool foobool(int argc) {
7*0a6a1f1dSLionel Sambuc return argc;
8*0a6a1f1dSLionel Sambuc }
9*0a6a1f1dSLionel Sambuc
10*0a6a1f1dSLionel Sambuc struct S1; // expected-note {{declared here}}
11*0a6a1f1dSLionel Sambuc
12*0a6a1f1dSLionel Sambuc template <class T, typename S, int N, int ST> // expected-note {{declared here}}
tmain(T argc,S ** argv)13*0a6a1f1dSLionel Sambuc T tmain(T argc, S **argv) { //expected-note 2 {{declared here}}
14*0a6a1f1dSLionel Sambuc #pragma omp simd collapse // expected-error {{expected '(' after 'collapse'}}
15*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
16*0a6a1f1dSLionel Sambuc #pragma omp simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
17*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
18*0a6a1f1dSLionel Sambuc #pragma omp simd collapse () // expected-error {{expected expression}}
19*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
20*0a6a1f1dSLionel Sambuc // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
21*0a6a1f1dSLionel Sambuc // expected-error@+2 2 {{expression is not an integral constant expression}}
22*0a6a1f1dSLionel Sambuc // expected-note@+1 2 {{read of non-const variable 'argc' is not allowed in a constant expression}}
23*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (argc
24*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
25*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{argument to 'collapse' clause must be a positive integer value}}
26*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (ST // expected-error {{expected ')'}} expected-note {{to match this '('}}
27*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
28*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (1)) // expected-warning {{extra tokens at the end of '#pragma omp simd' are ignored}}
29*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
30*0a6a1f1dSLionel Sambuc #pragma omp simd collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}}
31*0a6a1f1dSLionel Sambuc 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 simd', but found only 1}}
32*0a6a1f1dSLionel Sambuc // expected-error@+3 2 {{directive '#pragma omp simd' cannot contain more than one 'collapse' clause}}
33*0a6a1f1dSLionel Sambuc // expected-error@+2 2 {{argument to 'collapse' clause must be a positive integer value}}
34*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expression is not an integral constant expression}}
35*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (foobool(argc)), collapse (true), collapse (-5)
36*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
37*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (S) // expected-error {{'S' does not refer to a value}}
38*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
39*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{expression is not an integral constant expression}}
40*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
41*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
42*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (1)
43*0a6a1f1dSLionel Sambuc for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
44*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (N) // expected-error {{argument to 'collapse' clause must be a positive integer value}}
45*0a6a1f1dSLionel Sambuc for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
46*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
47*0a6a1f1dSLionel Sambuc foo(); // expected-error {{expected 2 for loops after '#pragma omp simd'}}
48*0a6a1f1dSLionel Sambuc return argc;
49*0a6a1f1dSLionel Sambuc }
50*0a6a1f1dSLionel Sambuc
main(int argc,char ** argv)51*0a6a1f1dSLionel Sambuc int main(int argc, char **argv) {
52*0a6a1f1dSLionel Sambuc #pragma omp simd collapse // expected-error {{expected '(' after 'collapse'}}
53*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
54*0a6a1f1dSLionel Sambuc #pragma omp simd collapse ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
55*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
56*0a6a1f1dSLionel Sambuc #pragma omp simd collapse () // expected-error {{expected expression}}
57*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
58*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{as specified in 'collapse' clause}}
59*0a6a1f1dSLionel Sambuc 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 simd', but found only 1}}
60*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp simd' are ignored}} expected-note {{as specified in 'collapse' clause}}
61*0a6a1f1dSLionel Sambuc 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 simd', but found only 1}}
62*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}}
63*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
64*0a6a1f1dSLionel Sambuc // expected-error@+3 {{expression is not an integral constant expression}}
65*0a6a1f1dSLionel Sambuc // expected-error@+2 2 {{directive '#pragma omp simd' cannot contain more than one 'collapse' clause}}
66*0a6a1f1dSLionel Sambuc // expected-error@+1 2 {{argument to 'collapse' clause must be a positive integer value}}
67*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (foobool(argc)), collapse (true), collapse (-5)
68*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
69*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (S1) // expected-error {{'S1' does not refer to a value}}
70*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
71*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expression is not an integral constant expression}}
72*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
73*0a6a1f1dSLionel Sambuc for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
74*0a6a1f1dSLionel Sambuc #pragma omp simd collapse (2) // expected-note {{as specified in 'collapse' clause}}
75*0a6a1f1dSLionel Sambuc foo(); // expected-error {{expected 2 for loops after '#pragma omp simd'}}
76*0a6a1f1dSLionel Sambuc // expected-error@+3 {{statement after '#pragma omp simd' must be a for loop}}
77*0a6a1f1dSLionel Sambuc // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}}
78*0a6a1f1dSLionel Sambuc #pragma omp simd collapse(collapse(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}}
79*0a6a1f1dSLionel Sambuc foo();
80*0a6a1f1dSLionel Sambuc // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 1, 0>' requested here}}
81*0a6a1f1dSLionel Sambuc return tmain<int, char, 1, 0>(argc, argv);
82*0a6a1f1dSLionel Sambuc }
83*0a6a1f1dSLionel Sambuc
84