brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.8 KiB · 58e1a81 Raw
334 lines · c
1// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s -Wuninitialized2 3// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized4 5void xxx(int argc) {6  int x; // expected-note {{initialize the variable 'x' to silence this warning}}7#pragma omp sections8{9  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}10}11}12 13void foo(void);14 15// expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}16#pragma omp sections17 18// expected-error@+1 {{unexpected OpenMP directive '#pragma omp sections'}}19#pragma omp sections foo20 21void test_no_clause(void) {22  int i;23#pragma omp sections24  {25    foo();26  }27 28// expected-error@+2 {{the statement for '#pragma omp sections' must be a compound statement}}29#pragma omp sections30  ++i;31 32#pragma omp sections33  {34    foo();35    foo(); // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}36  }37#pragma omp parallel38#pragma omp sections39  {40  {41    if (i == 6)42      return; // expected-error {{cannot return from OpenMP region}}43  }44#pragma omp section45  {46    if (i == 6)47      return; // expected-error {{cannot return from OpenMP region}}48  }49  }50 51}52 53void test_branch_protected_scope(void) {54  int i = 0;55L1:56  ++i;57 58  int x[24];59 60#pragma omp parallel61#pragma omp sections62  {63    if (i == 5)64      goto L1; // expected-error {{use of undeclared label 'L1'}}65    else if (i == 7)66      goto L2;67    else if (i == 8) {68    L2:69      x[i]++;70    }71#pragma omp section72    if (i == 5)73      goto L1;74    else if (i == 7)75      goto L3;76    else if (i == 8) {77    L3:78      x[i]++;79    }80  }81 82#pragma omp parallel83#pragma omp sections84  {85#pragma omp section86    if (i == 5)87      goto L1; // expected-error {{use of undeclared label 'L1'}}88    else if (i == 7)89      goto L3;90    else if (i == 8) {91    L3:92      x[i]++;93    }94  }95 96  if (x[0] == 0)97    goto L2; // expected-error {{use of undeclared label 'L2'}}98  else if (x[1] == 1)99    goto L1;100  goto L3; // expected-error {{use of undeclared label 'L3'}}101}102 103void test_invalid_clause(void) {104  int i;105#pragma omp parallel106// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}107#pragma omp sections foo bar108  {109    foo();110// expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}111#pragma omp section nowait112    ;113  }114}115 116void test_non_identifiers(void) {117  int i, x;118 119#pragma omp parallel120// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}121#pragma omp sections;122  {123    foo();124  }125#pragma omp parallel126// expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp sections'}}127// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}128#pragma omp sections linear(x);129  {130    foo();131  }132 133#pragma omp parallel134// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}135#pragma omp sections private(x);136  {137    foo();138  }139 140#pragma omp parallel141// expected-warning@+1 {{extra tokens at the end of '#pragma omp sections' are ignored}}142#pragma omp sections, private(x);143  {144    foo();145  }146}147 148void test_private(void) {149  int i;150#pragma omp parallel151// expected-error@+2 {{expected expression}}152// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}153#pragma omp sections private(154  {155    foo();156  }157#pragma omp parallel158// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}159// expected-error@+1 2 {{expected expression}}160#pragma omp sections private(,161  {162    foo();163  }164#pragma omp parallel165// expected-error@+1 2 {{expected expression}}166#pragma omp sections private(, )167  {168    foo();169  }170#pragma omp parallel171// expected-error@+1 {{expected expression}}172#pragma omp sections private()173  {174    foo();175  }176#pragma omp parallel177// expected-error@+1 {{expected expression}}178#pragma omp sections private(int)179  {180    foo();181  }182#pragma omp parallel183// expected-error@+1 {{expected variable name}}184#pragma omp sections private(0)185  {186    foo();187  }188 189  int x, y, z;190#pragma omp parallel191#pragma omp sections private(x)192  {193    foo();194  }195#pragma omp parallel196#pragma omp sections private(x, y)197  {198    foo();199  }200#pragma omp parallel201#pragma omp sections private(x, y, z)202  {203    foo();204  }205}206 207void test_lastprivate(void) {208  int i;209#pragma omp parallel210// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}211// expected-error@+1 {{expected expression}}212#pragma omp sections lastprivate(213  {214    foo();215  }216 217#pragma omp parallel218// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}219// expected-error@+1 2 {{expected expression}}220#pragma omp sections lastprivate(,221  {222    foo();223  }224#pragma omp parallel225// expected-error@+1 2 {{expected expression}}226#pragma omp sections lastprivate(, )227  {228    foo();229  }230#pragma omp parallel231// expected-error@+1 {{expected expression}}232#pragma omp sections lastprivate()233  {234    foo();235  }236#pragma omp parallel237// expected-error@+1 {{expected expression}}238#pragma omp sections lastprivate(int)239  {240    foo();241  }242#pragma omp parallel243// expected-error@+1 {{expected variable name}}244#pragma omp sections lastprivate(0)245  {246    foo();247  }248 249  int x, y, z;250#pragma omp parallel251#pragma omp sections lastprivate(x)252  {253    foo();254  }255#pragma omp parallel256#pragma omp sections lastprivate(x, y)257  {258    foo();259  }260#pragma omp parallel261#pragma omp sections lastprivate(x, y, z)262  {263    foo();264  }265}266 267void test_firstprivate(void) {268  int i;269#pragma omp parallel270// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}271// expected-error@+1 {{expected expression}}272#pragma omp sections firstprivate(273  {274    foo();275  }276 277#pragma omp parallel278// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}279// expected-error@+1 2 {{expected expression}}280#pragma omp sections firstprivate(,281  {282    foo();283  }284#pragma omp parallel285// expected-error@+1 2 {{expected expression}}286#pragma omp sections firstprivate(, )287  {288    foo();289  }290#pragma omp parallel291// expected-error@+1 {{expected expression}}292#pragma omp sections firstprivate()293  {294    foo();295  }296#pragma omp parallel297// expected-error@+1 {{expected expression}}298#pragma omp sections firstprivate(int)299  {300    foo();301  }302#pragma omp parallel303// expected-error@+1 {{expected variable name}}304#pragma omp sections firstprivate(0)305  {306    foo();307  }308 309  int x, y, z;310#pragma omp parallel311#pragma omp sections lastprivate(x) firstprivate(x)312  {313    foo();314  }315#pragma omp parallel316#pragma omp sections lastprivate(x, y) firstprivate(x, y)317  {318    foo();319  }320#pragma omp parallel321#pragma omp sections lastprivate(x, y, z) firstprivate(x, y, z)322  {323    foo();324  }325}326 327void test_nowait(void) {328#pragma omp parallel329#pragma omp sections nowait nowait // expected-error {{directive '#pragma omp sections' cannot contain more than one 'nowait' clause}}330  {331    ;332  }333}334