177 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized2 3// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized4 5// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized6// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized7 8void foo() {9}10 11bool foobool(int argc) {12 return argc;13}14 15void xxx(int argc) {16 int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}17#pragma omp parallel sections if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}18 {19 ;20 }21}22 23struct S1; // expected-note {{declared here}}24 25template <class T, class S> // expected-note {{declared here}}26int tmain(T argc, S **argv) {27 T z;28 #pragma omp parallel sections if // expected-error {{expected '(' after 'if'}}29 {30 foo();31 }32 #pragma omp parallel sections if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}33 {34 foo();35 }36 #pragma omp parallel sections if () // expected-error {{expected expression}}37 {38 foo();39 }40 #pragma omp parallel sections if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}41 {42 foo();43 }44 #pragma omp parallel sections if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}45 {46 foo();47 }48 #pragma omp parallel sections if (argc > 0 ? argv[1] : argv[2])49 {50 foo();51 }52 #pragma omp parallel sections if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause}}53 {54 foo();55 }56 #pragma omp parallel sections if (S) // expected-error {{'S' does not refer to a value}}57 {58 foo();59 }60 #pragma omp parallel sections if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}61 {62 foo();63 }64 #pragma omp parallel sections if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}65 {66 foo();67 }68 #pragma omp parallel sections if(argc + z)69 {70 foo();71 }72 #pragma omp parallel sections if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}73 {74 foo();75 }76 #pragma omp parallel sections if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}77 {78 foo();79 }80 #pragma omp parallel sections if(parallel : argc)81 {82 foo();83 }84 #pragma omp parallel sections if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp parallel sections'}}85 {86 foo();87 }88 #pragma omp parallel sections if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause with 'parallel' name modifier}}89 {90 foo();91 }92 #pragma omp parallel sections if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}93 {94 foo();95 }96 97 return 0;98}99 100int main(int argc, char **argv) {101 int z;102 #pragma omp parallel sections if // expected-error {{expected '(' after 'if'}}103 {104 foo();105 }106 #pragma omp parallel sections if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}107 {108 foo();109 }110 #pragma omp parallel sections if () // expected-error {{expected expression}}111 {112 foo();113 }114 #pragma omp parallel sections if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}115 {116 foo();117 }118 #pragma omp parallel sections if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}119 {120 foo();121 }122 #pragma omp parallel sections if (argc > 0 ? argv[1] : argv[2] + z)123 {124 foo();125 }126 #pragma omp parallel sections if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause}}127 {128 foo();129 }130 #pragma omp parallel sections if (S1) // expected-error {{'S1' does not refer to a value}}131 {132 foo();133 }134 #pragma omp parallel sections if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}135 {136 foo();137 }138 #pragma omp parallel sections if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}139 {140 foo();141 }142 #pragma omp parallel sections if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}143 {144 foo();145 }146 #pragma omp parallel sections if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}147 {148 foo();149 }150 #pragma omp parallel sections if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}151 {152 foo();153 }154 #pragma omp parallel sections if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}155 {156 foo();157 }158 #pragma omp parallel sections if(parallel : argc)159 {160 foo();161 }162 #pragma omp parallel sections if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp parallel sections'}}163 {164 foo();165 }166 #pragma omp parallel sections if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'if' clause with 'parallel' name modifier}}167 {168 foo();169 }170 #pragma omp parallel sections if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}171 {172 foo();173 }174 175 return tmain(argc, argv);176}177