1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized 2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wuninitialized 3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized 4 5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized 6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wuninitialized 7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized 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@+6 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} 60 #endif 61 #pragma omp target 62 // expected-error@+3 2 {{directive '#pragma omp teams distribute simd' cannot contain more than one 'safelen' clause}} 63 // expected-error@+2 {{argument to 'safelen' clause must be a strictly positive integer value}} 64 // expected-error@+1 2 {{expression is not an integral constant expression}} 65 #pragma omp teams distribute simd safelen (foobool(argc)), safelen (true), safelen (-5) 66 for (int i = ST; i < N; i++) 67 argv[0][i] = argv[0][i] - argv[0][i-ST]; 68 69 #pragma omp target 70 #pragma omp teams distribute simd safelen (S) // expected-error {{'S' does not refer to a value}} 71 for (int i = ST; i < N; i++) 72 argv[0][i] = argv[0][i] - argv[0][i-ST]; 73 74 #if __cplusplus <= 199711L 75 // expected-error@+5 2 {{expression is not an integral constant expression}} 76 #else 77 // expected-error@+3 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} 78 #endif 79 #pragma omp target 80 #pragma omp teams distribute simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} 81 for (int i = ST; i < N; i++) 82 argv[0][i] = argv[0][i] - argv[0][i-ST]; 83 84 #pragma omp target 85 #pragma omp teams distribute simd safelen (4) 86 for (int i = ST; i < N; i++) 87 argv[0][i] = argv[0][i] - argv[0][i-ST]; 88 89 #pragma omp target 90 #pragma omp teams distribute simd safelen (N) // expected-error {{argument to 'safelen' clause must be a strictly positive integer value}} 91 for (T i = ST; i < N; i++) 92 argv[0][i] = argv[0][i] - argv[0][i-ST]; 93 94 return argc; 95 } 96 97 int main(int argc, char **argv) { 98 #pragma omp target 99 #pragma omp teams distribute simd safelen // expected-error {{expected '(' after 'safelen'}} 100 for (int i = 4; i < 12; i++) 101 argv[0][i] = argv[0][i] - argv[0][i-4]; 102 103 #pragma omp target 104 #pragma omp teams distribute simd safelen ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 105 for (int i = 4; i < 12; i++) 106 argv[0][i] = argv[0][i] - argv[0][i-4]; 107 108 #pragma omp target 109 #pragma omp teams distribute simd safelen () // expected-error {{expected expression}} 110 for (int i = 4; i < 12; i++) 111 argv[0][i] = argv[0][i] - argv[0][i-4]; 112 113 #pragma omp target 114 #pragma omp teams distribute simd safelen (4 // expected-error {{expected ')'}} expected-note {{to match this '('}} 115 for (int i = 4; i < 12; i++) 116 argv[0][i] = argv[0][i] - argv[0][i-4]; 117 118 #pragma omp target 119 #pragma omp teams distribute simd safelen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}} 120 for (int i = 4; i < 12; i++) 121 argv[0][i] = argv[0][i] - argv[0][i-4]; 122 123 #if __cplusplus >= 201103L 124 // expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a constant expression}} 125 #endif 126 #pragma omp target 127 #pragma omp teams distribute simd safelen (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} 128 for (int i = 4; i < 12; i++) 129 argv[0][i] = argv[0][i] - argv[0][i-4]; 130 131 #if __cplusplus >= 201103L 132 // expected-note@+6 {{non-constexpr function 'foobool' cannot be used in a constant expression}} 133 #endif 134 #pragma omp target 135 // expected-error@+3 {{argument to 'safelen' clause must be a strictly positive integer value}} 136 // expected-error@+2 2 {{directive '#pragma omp teams distribute simd' cannot contain more than one 'safelen' clause}} 137 // expected-error@+1 {{expression is not an integral constant expression}} 138 #pragma omp teams distribute simd safelen (foobool(argc)), safelen (true), safelen (-5) 139 for (int i = 4; i < 12; i++) 140 argv[0][i] = argv[0][i] - argv[0][i-4]; 141 142 #pragma omp target 143 #pragma omp teams distribute simd safelen (S1) // expected-error {{'S1' does not refer to a value}} 144 for (int i = 4; i < 12; i++) 145 argv[0][i] = argv[0][i] - argv[0][i-4]; 146 147 #if __cplusplus <= 199711L 148 // expected-error@+5 {{expression is not an integral constant expression}} 149 #else 150 // expected-error@+3 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} 151 #endif 152 #pragma omp target 153 #pragma omp teams distribute simd safelen (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} 154 for (int i = 4; i < 12; i++) 155 argv[0][i] = argv[0][i] - argv[0][i-4]; 156 157 // expected-note@+2 {{in instantiation of function template specialization 'tmain<int, char, -1, -2>' requested here}} 158 #pragma omp target 159 #pragma omp teams distribute simd safelen(safelen(tmain<int, char, -1, -2>(argc, argv) // expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} 160 foo(); // expected-error {{statement after '#pragma omp teams distribute simd' must be a for loop}} 161 162 // expected-note@+1 {{in instantiation of function template specialization 'tmain<int, char, 12, 4>' requested here}} 163 return tmain<int, char, 12, 4>(argc, argv); 164 } 165 166