137 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized4 5void foo() {6}7 8bool foobool(int argc) {9 return argc;10}11 12void xxx(int argc) {13 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}14#pragma omp teams15#pragma omp distribute simd if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}16 for (int i = 0; i < 10; ++i)17 ;18}19 20struct S1; // expected-note {{declared here}}21 22template <class T, class S> // expected-note {{declared here}}23int tmain(T argc, S **argv) {24 T z;25 int i;26 #pragma omp teams27 #pragma omp distribute simd if // expected-error {{expected '(' after 'if'}}28 for (i = 0; i < argc; ++i) foo();29 #pragma omp teams30 #pragma omp distribute simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}31 for (i = 0; i < argc; ++i) foo();32 #pragma omp teams33 #pragma omp distribute simd if () // expected-error {{expected expression}}34 for (i = 0; i < argc; ++i) foo();35 #pragma omp teams36 #pragma omp distribute simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}37 for (i = 0; i < argc; ++i) foo();38 #pragma omp teams39 #pragma omp distribute simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}40 for (i = 0; i < argc; ++i) foo();41 #pragma omp teams42 #pragma omp distribute simd if (argc > 0 ? argv[1] : argv[2])43 for (i = 0; i < argc; ++i) foo();44 #pragma omp teams45 #pragma omp distribute simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute simd' cannot contain more than one 'if' clause}}46 for (i = 0; i < argc; ++i) foo();47 #pragma omp teams48 #pragma omp distribute simd if (S) // expected-error {{'S' does not refer to a value}}49 for (i = 0; i < argc; ++i) foo();50 #pragma omp teams51 #pragma omp distribute simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}52 for (i = 0; i < argc; ++i) foo();53 #pragma omp teams54 #pragma omp distribute simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}55 for (i = 0; i < argc; ++i) foo();56 #pragma omp teams57 #pragma omp distribute simd if(argc + z)58 for (i = 0; i < argc; ++i) foo();59 #pragma omp teams60 #pragma omp distribute simd if(simd : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}61 for (i = 0; i < argc; ++i) foo();62 #pragma omp teams63 #pragma omp distribute simd if(simd : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}64 for (i = 0; i < argc; ++i) foo();65 #pragma omp teams66 #pragma omp distribute simd if(simd : argc)67 for (i = 0; i < argc; ++i) foo();68 #pragma omp teams69 #pragma omp distribute simd if(target : argc) // expected-error {{directive name modifier 'target' is not allowed for '#pragma omp distribute simd'}}70 for (i = 0; i < argc; ++i) foo();71 #pragma omp teams72 #pragma omp distribute simd if(simd : argc) if (simd :argc) // expected-error {{directive '#pragma omp distribute simd' cannot contain more than one 'if' clause with 'simd' name modifier}}73 for (i = 0; i < argc; ++i) foo();74 #pragma omp teams75 #pragma omp distribute simd if(simd : argc) if (argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{no more 'if' clause is allowed}}76 for (i = 0; i < argc; ++i) foo();77 78 return 0;79}80 81int main(int argc, char **argv) {82 int i, z;83 #pragma omp teams84 #pragma omp distribute simd if // expected-error {{expected '(' after 'if'}}85 for (i = 0; i < argc; ++i) foo();86 #pragma omp teams87 #pragma omp distribute simd if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}88 for (i = 0; i < argc; ++i) foo();89 #pragma omp teams90 #pragma omp distribute simd if () // expected-error {{expected expression}}91 for (i = 0; i < argc; ++i) foo();92 #pragma omp teams93 #pragma omp distribute simd if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}94 for (i = 0; i < argc; ++i) foo();95 #pragma omp teams96 #pragma omp distribute simd if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}97 for (i = 0; i < argc; ++i) foo();98 #pragma omp teams99 #pragma omp distribute simd if (argc > 0 ? argv[1] : argv[2])100 for (i = 0; i < argc; ++i) foo();101 #pragma omp teams102 #pragma omp distribute simd if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute simd' cannot contain more than one 'if' clause}}103 for (i = 0; i < argc; ++i) foo();104 #pragma omp teams105 #pragma omp distribute simd if (S1) // expected-error {{'S1' does not refer to a value}}106 for (i = 0; i < argc; ++i) foo();107 #pragma omp teams108 #pragma omp distribute simd if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}109 for (i = 0; i < argc; ++i) foo();110 #pragma omp teams111 #pragma omp distribute simd if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}112 for (i = 0; i < argc; ++i) foo();113 #pragma omp teams114 #pragma omp distribute simd if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}115 for (i = 0; i < argc; ++i) foo();116 #pragma omp teams117 #pragma omp distribute simd if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}118 for (i = 0; i < argc; ++i) foo();119 #pragma omp teams120 #pragma omp distribute simd if(simd : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}121 for (i = 0; i < argc; ++i) foo();122 #pragma omp teams123 #pragma omp distribute simd if(simd : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}124 for (i = 0; i < argc; ++i) foo();125 #pragma omp teams126 #pragma omp distribute simd if(simd : argc + z) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute simd'}}127 for (i = 0; i < argc; ++i) foo();128 #pragma omp teams129 #pragma omp distribute simd if(simd : argc) if (simd :argc) // expected-error {{directive '#pragma omp distribute simd' cannot contain more than one 'if' clause with 'simd' name modifier}}130 for (i = 0; i < argc; ++i) foo();131 #pragma omp teams132 #pragma omp distribute simd if(simd : argc) if (argc) // expected-note {{previous clause with directive name modifier specified here}} expected-error {{no more 'if' clause is allowed}}133 for (i = 0; i < argc; ++i) foo();134 135 return tmain(argc, argv);136}137