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