brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.4 KiB · 9a7267c Raw
163 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized4 5int foo();6 7void xxx(int argc) {8  int x; // expected-note {{initialize the variable 'x' to silence this warning}}9#pragma omp critical10  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}11}12 13template<typename T, int N>14int tmain(int argc, char **argv) { // expected-note {{declared here}}15  #pragma omp critical16  ;17  #pragma omp critical untied allocate(argc) // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}} expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp critical'}}18  #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}19  #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}20  #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}21  #pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}}22  #pragma omp critical (name1)23  foo();24  {25    #pragma omp critical26  } // expected-error {{expected statement}}27  #pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}}28  #pragma omp critical29  for (int i = 0; i < 10; ++i) {30    foo();31    #pragma omp parallel32    #pragma omp for33    for (int j = 0; j < 10; j++) {34      foo();35      #pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}}36      foo();37    }38  }39  #pragma omp critical (name2)40  #pragma omp critical41  for (int i = 0; i < 10; ++i) {42    foo();43    #pragma omp parallel44    #pragma omp for45    for (int j = 0; j < 10; j++) {46      #pragma omp critical47      foo();48    }49  }50  #pragma omp critical (name2)51  #pragma omp critical52  for (int i = 0; i < 10; ++i) {53    foo();54    #pragma omp parallel55    #pragma omp for56    for (int j = 0; j < 10; j++) {57      #pragma omp critical (nam)58      foo();59    }60  }61 62  #pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}}63  foo();64  #pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}65  foo();66  #pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}67  foo();68  #pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}69  foo();70  #pragma omp critical (name) hint(N) // expected-error {{argument to 'hint' clause must be a non-negative 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'}}71  foo();72  #pragma omp critical hint(N) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}}73  foo();74 75  const int omp_lock_hint_none = 0;76  #pragma omp critical (name3) hint(omp_lock_hint_none)77  foo();78  return 0;79}80 81int main(int argc, char **argv) { // expected-note {{declared here}}82  #pragma omp critical83  ;84  #pragma omp critical untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp critical'}}85  #pragma omp critical unknown // expected-warning {{extra tokens at the end of '#pragma omp critical' are ignored}}86  #pragma omp critical ( // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}87  #pragma omp critical ( + // expected-error {{expected identifier}} expected-error {{expected ')'}} expected-note {{to match this '('}}88  #pragma omp critical (name2 // expected-error {{expected ')'}} expected-note {{to match this '('}}89  #pragma omp critical (name1)90  foo();91  {92    #pragma omp critical93  } // expected-error {{expected statement}}94  #pragma omp critical (name2) // expected-note {{previous 'critical' region starts here}}95  #pragma omp critical96  for (int i = 0; i < 10; ++i) {97    foo();98    #pragma omp parallel99    #pragma omp for100    for (int j = 0; j < 10; j++) {101      foo();102      #pragma omp critical(name2) // expected-error {{cannot nest 'critical' regions having the same name 'name2'}}103      foo();104    }105  }106  #pragma omp critical (name2)107  #pragma omp critical108  for (int i = 0; i < 10; ++i) {109    foo();110    #pragma omp parallel111    #pragma omp for112    for (int j = 0; j < 10; j++) {113      #pragma omp critical114      foo();115    }116  }117  #pragma omp critical (name2)118  #pragma omp critical119  for (int i = 0; i < 10; ++i) {120    foo();121    #pragma omp parallel122    #pragma omp for123    for (int j = 0; j < 10; j++) {124      #pragma omp critical (nam)125      foo();126    }127  }128 129  #pragma omp critical (name2) hint // expected-error {{expected '(' after 'hint'}}130  foo();131  #pragma omp critical (name2) hint( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}132  foo();133  #pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}134  foo();135  #pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}136  foo();137  #pragma omp critical (name) hint(23) // expected-note {{previous 'hint' clause with value '23'}}138  foo();139  #pragma omp critical hint(-5) // expected-error {{argument to 'hint' clause must be a non-negative integer value}}140  foo();141  #pragma omp critical hint(1) // expected-error {{the name of the construct must be specified in presence of 'hint' clause}}142  foo();143  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}}144}145 146int foo() {147  L1: // expected-note {{jump exits scope of OpenMP structured block}}148    foo();149  #pragma omp critical150  {151    foo();152    goto L1; // expected-error {{cannot jump from this goto statement to its label}}153  }154  goto L2; // expected-error {{cannot jump from this goto statement to its label}}155  #pragma omp critical156  {  // expected-note {{jump bypasses OpenMP structured block}}157    L2:158    foo();159  }160 161  return 0;162 }163