1 // RUN: %clang_cc1 -verify -fopenmp %s 2 3 int foo(); 4 5 template<typename T, int N> 6 int tmain(int argc, char **argv) { // expected-note {{declared here}} 7 #pragma omp critical 8 ; 9 #pragma omp critical untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}} 10 #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}} 11 #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} 12 #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} 13 #pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}} 14 #pragma omp critical (name1) 15 foo(); 16 { 17 #pragma omp critical 18 } // expected-error {{expected statement}} 19 #pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}} 20 #pragma omp critical 21 for (int i = 0; i < 10; ++i) { 22 foo(); 23 #pragma omp parallel 24 #pragma omp for 25 for (int j = 0; j < 10; j++) { 26 foo(); 27 #pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}} 28 foo(); 29 } 30 } 31 #pragma omp critical (name2) 32 #pragma omp critical 33 for (int i = 0; i < 10; ++i) { 34 foo(); 35 #pragma omp parallel 36 #pragma omp for 37 for (int j = 0; j < 10; j++) { 38 #pragma omp critical 39 foo(); 40 } 41 } 42 #pragma omp critical (name2) 43 #pragma omp critical 44 for (int i = 0; i < 10; ++i) { 45 foo(); 46 #pragma omp parallel 47 #pragma omp for 48 for (int j = 0; j < 10; j++) { 49 #pragma omp critical (nam) 50 foo(); 51 } 52 } 53 54 #pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}} 55 foo(); 56 #pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 57 foo(); 58 #pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 59 foo(); 60 #pragma omp critical (name2) hint(argc) // expected-error {{expression is not an integral constant expression}} expected-note {{read of non-const variable 'argc' is not allowed in a constant expression}} 61 foo(); 62 #pragma omp critical (name) hint(N) // expected-error {{argument to 'hint' clause must be a strictly positive integer value}} expected-error {{constructs with the same name must have a 'hint' clause with the same value}} expected-note {{'hint' clause with value '4'}} 63 foo(); 64 #pragma omp critical hint(N) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}} 65 foo(); 66 return 0; 67 } 68 69 int main(int argc, char **argv) { // expected-note {{declared here}} 70 #pragma omp critical 71 ; 72 #pragma omp critical untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}} 73 #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}} 74 #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} 75 #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}} 76 #pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}} 77 #pragma omp critical (name1) 78 foo(); 79 { 80 #pragma omp critical 81 } // expected-error {{expected statement}} 82 #pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}} 83 #pragma omp critical 84 for (int i = 0; i < 10; ++i) { 85 foo(); 86 #pragma omp parallel 87 #pragma omp for 88 for (int j = 0; j < 10; j++) { 89 foo(); 90 #pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}} 91 foo(); 92 } 93 } 94 #pragma omp critical (name2) 95 #pragma omp critical 96 for (int i = 0; i < 10; ++i) { 97 foo(); 98 #pragma omp parallel 99 #pragma omp for 100 for (int j = 0; j < 10; j++) { 101 #pragma omp critical 102 foo(); 103 } 104 } 105 #pragma omp critical (name2) 106 #pragma omp critical 107 for (int i = 0; i < 10; ++i) { 108 foo(); 109 #pragma omp parallel 110 #pragma omp for 111 for (int j = 0; j < 10; j++) { 112 #pragma omp critical (nam) 113 foo(); 114 } 115 } 116 117 #pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}} 118 foo(); 119 #pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 120 foo(); 121 #pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 122 foo(); 123 #pragma omp critical (name2) hint(argc) // expected-error {{expression is not an integral constant expression}} expected-note {{read of non-const variable 'argc' is not allowed in a constant expression}} 124 foo(); 125 #pragma omp critical (name) hint(23) // expected-note {{previous 'hint' clause with value '23'}} 126 foo(); 127 #pragma omp critical hint(-5) // expected-error {{argument to 'hint' clause must be a strictly positive integer value}} 128 foo(); 129 #pragma omp critical hint(1) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}} 130 foo(); 131 return tmain<int, 4>(argc, argv) + tmain<float, -5>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<float, -5>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}} 132 } 133 134 int foo() { 135 L1: 136 foo(); 137 #pragma omp critical 138 { 139 foo(); 140 goto L1; // expected-error {{use of undeclared label 'L1'}} 141 } 142 goto L2; // expected-error {{use of undeclared label 'L2'}} 143 #pragma omp critical 144 { 145 L2: 146 foo(); 147 } 148 149 return 0; 150 } 151