1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ferror-limit 150 %s 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -ferror-limit 150 %s 4 5 template <class T> 6 T tmain() { 7 static T argc; 8 #pragma omp for 9 for (int i = 0; i < 10; ++i) { 10 #pragma omp scan // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 11 ; 12 } 13 #pragma omp for 14 for (int i = 0; i < 10; ++i) { 15 #pragma omp scan allocate(argc) // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp scan'}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 16 #pragma omp scan untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp scan'}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 17 #pragma omp scan unknown // expected-warning {{extra tokens at the end of '#pragma omp scan' are ignored}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 18 } 19 #pragma omp for simd reduction(inscan, +: argc) 20 for (int i = 0; i < 10; ++i) 21 if (argc) 22 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 23 if (argc) { 24 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} 25 } 26 #pragma omp simd reduction(inscan, +: argc) 27 for (int i = 0; i < 10; ++i) 28 while (argc) 29 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 30 while (argc) { 31 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} 32 } 33 #pragma omp simd reduction(inscan, +: argc) 34 for (int i = 0; i < 10; ++i) 35 do 36 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 37 while (argc) 38 ; 39 #pragma omp simd reduction(inscan, +: argc) 40 for (int i = 0; i < 10; ++i) 41 do { 42 #pragma omp scan inclusive(argc) 43 } while (argc); 44 #pragma omp simd reduction(inscan, +: argc) 45 for (int i = 0; i < 10; ++i) 46 switch (argc) 47 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 48 switch (argc) 49 case 1: 50 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} 51 switch (argc) 52 case 1: { 53 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} 54 } 55 #pragma omp simd reduction(inscan, +: argc) 56 for (int i = 0; i < 10; ++i) 57 switch (argc) { 58 #pragma omp scan exclusive(argc) // expected-note 2 {{previous 'scan' directive used here}} 59 case 1: 60 #pragma omp scan exclusive(argc) // expected-error {{exactly one 'scan' directive must appear in the loop body of an enclosing directive}} 61 break; 62 default: { 63 #pragma omp scan exclusive(argc) // expected-error {{exactly one 'scan' directive must appear in the loop body of an enclosing directive}} 64 } break; 65 } 66 #pragma omp simd reduction(inscan, +: argc) 67 for (int i = 0; i < 10; ++i) 68 for (;;) 69 #pragma omp scan exclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 70 for (;;) { 71 #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} 72 } 73 #pragma omp simd reduction(inscan, +: argc) 74 for (int i = 0; i < 10; ++i) { 75 label: 76 #pragma omp scan exclusive(argc) 77 } 78 #pragma omp simd reduction(inscan, +: argc) 79 for (int i = 0; i < 10; ++i) { 80 label1 : { 81 #pragma omp scan inclusive(argc) 82 }} 83 84 return T(); 85 } 86 87 int main() { 88 static int argc; 89 #pragma omp simd reduction(inscan, +: argc) 90 for (int i = 0; i < 10; ++i) { 91 #pragma omp scan inclusive(argc) inclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 92 ; 93 } 94 #pragma omp simd reduction(inscan, +: argc) 95 for (int i = 0; i < 10; ++i) { 96 #pragma omp scan exclusive(argc) inclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 97 ; 98 } 99 #pragma omp simd reduction(inscan, +: argc) 100 for (int i = 0; i < 10; ++i) { 101 #pragma omp scan exclusive(argc) exclusive(argc) // expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 102 ; 103 } 104 #pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}} 105 for (int i = 0; i < 10; ++i) { 106 #pragma omp scan untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp scan'}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 107 #pragma omp scan unknown // expected-warning {{extra tokens at the end of '#pragma omp scan' are ignored}} expected-error {{exactly one of 'inclusive' or 'exclusive' clauses is expected}} 108 } 109 #pragma omp simd reduction(inscan, +: argc) 110 for (int i = 0; i < 10; ++i) 111 if (argc) 112 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 113 if (argc) { 114 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}} 115 } 116 #pragma omp simd reduction(inscan, +: argc) 117 for (int i = 0; i < 10; ++i) 118 while (argc) 119 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 120 while (argc) { 121 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}} 122 } 123 #pragma omp simd reduction(inscan, +: argc) 124 for (int i = 0; i < 10; ++i) 125 do 126 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 127 while (argc) 128 ; 129 #pragma omp simd reduction(inscan, +: argc) 130 for (int i = 0; i < 10; ++i) 131 do { 132 #pragma omp scan exclusive(argc) 133 } while (argc); 134 #pragma omp simd reduction(inscan, +: argc) 135 for (int i = 0; i < 10; ++i) 136 switch (argc) 137 #pragma omp scan exclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 138 switch (argc) 139 case 1: 140 #pragma omp scan exclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}} 141 switch (argc) 142 case 1: { 143 #pragma omp scan exclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}} 144 } 145 #pragma omp simd reduction(inscan, +: argc) 146 for (int i = 0; i < 10; ++i) 147 switch (argc) { 148 #pragma omp scan inclusive(argc) // expected-note 2 {{previous 'scan' directive used here}} 149 case 1: 150 #pragma omp scan inclusive(argc) // expected-error {{exactly one 'scan' directive must appear in the loop body of an enclosing directive}} 151 break; 152 default: { 153 #pragma omp scan inclusive(argc) // expected-error {{exactly one 'scan' directive must appear in the loop body of an enclosing directive}} 154 } break; 155 } 156 #pragma omp simd reduction(inscan, +: argc) 157 for (int i = 0; i < 10; ++i) 158 for (;;) 159 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} 160 for (;;) { 161 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}} expected-error {{the list item must appear in 'reduction' clause with the 'inscan' modifier of the parent directive}} 162 } 163 #pragma omp simd reduction(inscan, +: argc) 164 for (int i = 0; i < 10; ++i) { 165 label: 166 #pragma omp scan inclusive(argc) 167 } 168 #pragma omp simd reduction(inscan, +: argc) 169 for (int i = 0; i < 10; ++i) { 170 label1 : { 171 #pragma omp scan inclusive(argc) 172 } 173 } 174 175 return tmain<int>(); 176 } 177