brintos

brintos / llvm-project-archived public Read only

0
0
Text · 18.2 KiB · eb9131d Raw
471 lines · c
1// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45 -triple x86_64-unknown-unknown %s -Wuninitialized2// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp51 -triple x86_64-unknown-unknown %s -Wuninitialized3 4// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 -triple x86_64-unknown-unknown %s -Wuninitialized5// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp51 -triple x86_64-unknown-unknown %s -Wuninitialized6 7void xxx(int argc) {8  int x; // expected-note {{initialize the variable 'x' to silence this warning}}9#pragma omp parallel master taskloop simd10  for (int i = 0; i < 10; ++i)11    argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}12}13 14// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel master taskloop simd'}}15#pragma omp parallel master taskloop simd16 17// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel master taskloop simd'}}18#pragma omp parallel master taskloop simd foo19 20void test_no_clause(void) {21  int i;22#pragma omp parallel master taskloop simd23  for (i = 0; i < 16; ++i)24    ;25 26// expected-error@+2 {{statement after '#pragma omp parallel master taskloop simd' must be a for loop}}27#pragma omp parallel master taskloop simd28  ++i;29}30 31void test_branch_protected_scope(void) {32  int i = 0;33L1:34  ++i;35 36  int x[24];37 38#pragma omp parallel39#pragma omp parallel master taskloop simd40  for (i = 0; i < 16; ++i) {41    if (i == 5)42      goto L1; // expected-error {{use of undeclared label 'L1'}}43    else if (i == 6)44      return; // expected-error {{cannot return from OpenMP region}}45    else if (i == 7)46      goto L2;47    else if (i == 8) {48    L2:49      x[i]++;50    }51  }52 53  if (x[0] == 0)54    goto L2; // expected-error {{use of undeclared label 'L2'}}55  else if (x[1] == 1)56    goto L1;57}58 59void test_invalid_clause(void) {60  int i, a;61// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}62#pragma omp parallel master taskloop simd foo bar63  for (i = 0; i < 16; ++i)64    ;65// expected-error@+1 {{directive '#pragma omp parallel master taskloop simd' cannot contain more than one 'nogroup' clause}}66#pragma omp parallel master taskloop simd nogroup nogroup67  for (i = 0; i < 16; ++i)68    ;69// expected-error@+1 {{unexpected OpenMP clause 'in_reduction' in directive '#pragma omp parallel master taskloop simd'}}70#pragma omp parallel master taskloop simd in_reduction(+:a)71  for (i = 0; i < 16; ++i)72    ;73}74 75void test_non_identifiers(void) {76  int i, x;77 78#pragma omp parallel79// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}80#pragma omp parallel master taskloop simd;81  for (i = 0; i < 16; ++i)82    ;83// expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}84#pragma omp parallel85#pragma omp parallel master taskloop simd linear(x);86  for (i = 0; i < 16; ++i)87    ;88 89#pragma omp parallel90// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}91#pragma omp parallel master taskloop simd private(x);92  for (i = 0; i < 16; ++i)93    ;94 95#pragma omp parallel96// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}97#pragma omp parallel master taskloop simd, private(x);98  for (i = 0; i < 16; ++i)99    ;100}101 102extern int foo(void);103 104void test_collapse(void) {105  int i;106#pragma omp parallel107// expected-error@+1 {{expected '('}}108#pragma omp parallel master taskloop simd collapse109  for (i = 0; i < 16; ++i)110    ;111#pragma omp parallel112// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}113#pragma omp parallel master taskloop simd collapse(114  for (i = 0; i < 16; ++i)115    ;116#pragma omp parallel117// expected-error@+1 {{expected expression}}118#pragma omp parallel master taskloop simd collapse()119  for (i = 0; i < 16; ++i)120    ;121#pragma omp parallel122// expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}123#pragma omp parallel master taskloop simd collapse(,124  for (i = 0; i < 16; ++i)125    ;126#pragma omp parallel127// expected-error@+1 {{expected expression}}  expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}128#pragma omp parallel master taskloop simd collapse(, )129  for (i = 0; i < 16; ++i)130    ;131#pragma omp parallel132// expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}133// expected-error@+1 {{expected '('}}134#pragma omp parallel master taskloop simd collapse 4)135  for (i = 0; i < 16; ++i)136    ;137#pragma omp parallel138// expected-error@+2 {{expected ')'}}139// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}140#pragma omp parallel master taskloop simd collapse(4141  for (i = 0; i < 16; ++i)142    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}143#pragma omp parallel144// expected-error@+2 {{expected ')'}}145// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}146#pragma omp parallel master taskloop simd collapse(4,147  for (i = 0; i < 16; ++i)148    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}149#pragma omp parallel150// expected-error@+2 {{expected ')'}}151// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}152#pragma omp parallel master taskloop simd collapse(4, )153  for (i = 0; i < 16; ++i)154    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}155#pragma omp parallel156// expected-note@+1 {{as specified in 'collapse' clause}}157#pragma omp parallel master taskloop simd collapse(4)158  for (i = 0; i < 16; ++i)159    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}160#pragma omp parallel161// expected-error@+2 {{expected ')'}}162// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}163#pragma omp parallel master taskloop simd collapse(4 4)164  for (i = 0; i < 16; ++i)165    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}166#pragma omp parallel167// expected-error@+2 {{expected ')'}}168// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}169#pragma omp parallel master taskloop simd collapse(4, , 4)170  for (i = 0; i < 16; ++i)171    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}172#pragma omp parallel173#pragma omp parallel master taskloop simd collapse(4)174  for (int i1 = 0; i1 < 16; ++i1)175    for (int i2 = 0; i2 < 16; ++i2)176      for (int i3 = 0; i3 < 16; ++i3)177        for (int i4 = 0; i4 < 16; ++i4)178          foo();179#pragma omp parallel180// expected-error@+2 {{expected ')'}}181// expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}182#pragma omp parallel master taskloop simd collapse(4, 8)183  for (i = 0; i < 16; ++i)184    ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}185#pragma omp parallel186// expected-error@+1 {{integer constant expression}}187#pragma omp parallel master taskloop simd collapse(2.5)188  for (i = 0; i < 16; ++i)189    ;190#pragma omp parallel191// expected-error@+1 {{integer constant expression}}192#pragma omp parallel master taskloop simd collapse(foo())193  for (i = 0; i < 16; ++i)194    ;195#pragma omp parallel196// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}197#pragma omp parallel master taskloop simd collapse(-5)198  for (i = 0; i < 16; ++i)199    ;200#pragma omp parallel201// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}202#pragma omp parallel master taskloop simd collapse(0)203  for (i = 0; i < 16; ++i)204    ;205#pragma omp parallel206// expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}207#pragma omp parallel master taskloop simd collapse(5 - 5)208  for (i = 0; i < 16; ++i)209    ;210}211 212void test_private(void) {213  int i;214#pragma omp parallel215// expected-error@+2 {{expected expression}}216// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}217#pragma omp parallel master taskloop simd private(218  for (i = 0; i < 16; ++i)219    ;220#pragma omp parallel221// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}222// expected-error@+1 2 {{expected expression}}223#pragma omp parallel master taskloop simd private(,224  for (i = 0; i < 16; ++i)225    ;226#pragma omp parallel227// expected-error@+1 2 {{expected expression}}228#pragma omp parallel master taskloop simd private(, )229  for (i = 0; i < 16; ++i)230    ;231#pragma omp parallel232// expected-error@+1 {{expected expression}}233#pragma omp parallel master taskloop simd private()234  for (i = 0; i < 16; ++i)235    ;236#pragma omp parallel237// expected-error@+1 {{expected expression}}238#pragma omp parallel master taskloop simd private(int)239  for (i = 0; i < 16; ++i)240    ;241#pragma omp parallel242// expected-error@+1 {{expected variable name}}243#pragma omp parallel master taskloop simd private(0)244  for (i = 0; i < 16; ++i)245    ;246 247  int x, y, z;248#pragma omp parallel249#pragma omp parallel master taskloop simd private(x)250  for (i = 0; i < 16; ++i)251    ;252#pragma omp parallel253#pragma omp parallel master taskloop simd private(x, y)254  for (i = 0; i < 16; ++i)255    ;256#pragma omp parallel257#pragma omp parallel master taskloop simd private(x, y, z)258  for (i = 0; i < 16; ++i) {259    x = y * i + z;260  }261}262 263void test_lastprivate(void) {264  int i;265#pragma omp parallel266// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}267// expected-error@+1 {{expected expression}}268#pragma omp parallel master taskloop simd lastprivate(269  for (i = 0; i < 16; ++i)270    ;271 272#pragma omp parallel273// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}274// expected-error@+1 2 {{expected expression}}275#pragma omp parallel master taskloop simd lastprivate(,276  for (i = 0; i < 16; ++i)277    ;278#pragma omp parallel279// expected-error@+1 2 {{expected expression}}280#pragma omp parallel master taskloop simd lastprivate(, )281  for (i = 0; i < 16; ++i)282    ;283#pragma omp parallel284// expected-error@+1 {{expected expression}}285#pragma omp parallel master taskloop simd lastprivate()286  for (i = 0; i < 16; ++i)287    ;288#pragma omp parallel289// expected-error@+1 {{expected expression}}290#pragma omp parallel master taskloop simd lastprivate(int)291  for (i = 0; i < 16; ++i)292    ;293#pragma omp parallel294// expected-error@+1 {{expected variable name}}295#pragma omp parallel master taskloop simd lastprivate(0)296  for (i = 0; i < 16; ++i)297    ;298 299  int x, y, z;300#pragma omp parallel301#pragma omp parallel master taskloop simd lastprivate(x)302  for (i = 0; i < 16; ++i)303    ;304#pragma omp parallel305#pragma omp parallel master taskloop simd lastprivate(x, y)306  for (i = 0; i < 16; ++i)307    ;308#pragma omp parallel309#pragma omp parallel master taskloop simd lastprivate(x, y, z)310  for (i = 0; i < 16; ++i)311    ;312}313 314void test_firstprivate(void) {315  int i;316#pragma omp parallel317// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}318// expected-error@+1 {{expected expression}}319#pragma omp parallel master taskloop simd firstprivate(320  for (i = 0; i < 16; ++i)321    ;322 323#pragma omp parallel324// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}325// expected-error@+1 2 {{expected expression}}326#pragma omp parallel master taskloop simd firstprivate(,327  for (i = 0; i < 16; ++i)328    ;329#pragma omp parallel330// expected-error@+1 2 {{expected expression}}331#pragma omp parallel master taskloop simd firstprivate(, )332  for (i = 0; i < 16; ++i)333    ;334#pragma omp parallel335// expected-error@+1 {{expected expression}}336#pragma omp parallel master taskloop simd firstprivate()337  for (i = 0; i < 16; ++i)338    ;339#pragma omp parallel340// expected-error@+1 {{expected expression}}341#pragma omp parallel master taskloop simd firstprivate(int)342  for (i = 0; i < 16; ++i)343    ;344#pragma omp parallel345// expected-error@+1 {{expected variable name}}346#pragma omp parallel master taskloop simd firstprivate(0)347  for (i = 0; i < 16; ++i)348    ;349 350  int x, y, z;351#pragma omp parallel352#pragma omp parallel master taskloop simd lastprivate(x) firstprivate(x)353  for (i = 0; i < 16; ++i)354    ;355#pragma omp parallel356#pragma omp parallel master taskloop simd lastprivate(x, y) firstprivate(x, y)357  for (i = 0; i < 16; ++i)358    ;359#pragma omp parallel360#pragma omp parallel master taskloop simd lastprivate(x, y, z) firstprivate(x, y, z)361  for (i = 0; i < 16; ++i)362    ;363}364 365void test_loop_messages(void) {366  float a[100], b[100], c[100];367#pragma omp parallel368// expected-error@+2 {{variable must be of integer or pointer type}}369#pragma omp parallel master taskloop simd370  for (float fi = 0; fi < 10.0; fi++) {371    c[(int)fi] = a[(int)fi] + b[(int)fi];372  }373#pragma omp parallel374// expected-error@+2 {{variable must be of integer or pointer type}}375#pragma omp parallel master taskloop simd376  for (double fi = 0; fi < 10.0; fi++) {377    c[(int)fi] = a[(int)fi] + b[(int)fi];378  }379 380  // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}381  #pragma omp parallel master taskloop simd382  for (__int128 ii = 0; ii < 10; ii++) {383    c[ii] = a[ii] + b[ii];384  }385}386 387void test_nontemporal(void) {388  int i;389// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}390#pragma omp parallel master taskloop simd nontemporal(391  for (i = 0; i < 16; ++i)392    ;393// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}394#pragma omp parallel master taskloop simd nontemporal(,395  for (i = 0; i < 16; ++i)396    ;397// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 2 {{expected expression}}398#pragma omp parallel master taskloop simd nontemporal(, )399  for (i = 0; i < 16; ++i)400    ;401// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected expression}}402#pragma omp parallel master taskloop simd nontemporal()403  for (i = 0; i < 16; ++i)404    ;405// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected expression}}406#pragma omp parallel master taskloop simd nontemporal(int)407  for (i = 0; i < 16; ++i)408    ;409// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} omp51-error@+1 {{expected variable name}}410#pragma omp parallel master taskloop simd nontemporal(0)411  for (i = 0; i < 16; ++i)412    ;413// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}414#pragma omp parallel master taskloop simd nontemporal(x)415  for (i = 0; i < 16; ++i)416    ;417// expected-error@+2 {{use of undeclared identifier 'x'}}418// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}419#pragma omp parallel master taskloop simd nontemporal(x, y)420  for (i = 0; i < 16; ++i)421    ;422// expected-error@+3 {{use of undeclared identifier 'x'}}423// expected-error@+2 {{use of undeclared identifier 'y'}}424// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}425#pragma omp parallel master taskloop simd nontemporal(x, y, z)426  for (i = 0; i < 16; ++i)427    ;428 429  int x, y;430// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}431#pragma omp parallel master taskloop simd nontemporal(x :)432  for (i = 0; i < 16; ++i)433    ;434// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}435#pragma omp parallel master taskloop simd nontemporal(x :, )436  for (i = 0; i < 16; ++i)437    ;438 439// omp51-note@+2 {{defined as nontemporal}}440// omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} omp51-error@+1 {{a variable cannot appear in more than one nontemporal clause}}441#pragma omp parallel master taskloop simd nontemporal(x) nontemporal(x)442  for (i = 0; i < 16; ++i)443    ;444 445// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}446#pragma omp parallel master taskloop simd private(x) nontemporal(x)447  for (i = 0; i < 16; ++i)448    ;449 450// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}451#pragma omp parallel master taskloop simd nontemporal(x) private(x)452  for (i = 0; i < 16; ++i)453    ;454 455// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}456#pragma omp parallel master taskloop simd nontemporal(x, y : 0)457  for (i = 0; i < 16; ++i)458    ;459 460// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}461#pragma omp parallel master taskloop simd nontemporal(x) lastprivate(x)462  for (i = 0; i < 16; ++i)463    ;464 465// omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}466#pragma omp parallel master taskloop simd lastprivate(x) nontemporal(x)467  for (i = 0; i < 16; ++i)468    ;469}470 471