263 lines · c
1// RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s -Wuninitialized2 3// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized4 5void foo(void);6 7// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel sections'}}8#pragma omp parallel sections9 10// expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel sections'}}11#pragma omp parallel sections foo12 13void test_no_clause(void) {14 int i;15#pragma omp parallel sections16 {17 foo();18 }19 20// expected-error@+2 {{the statement for '#pragma omp parallel sections' must be a compound statement}}21#pragma omp parallel sections22 ++i;23 24#pragma omp parallel sections25 {26 foo();27 foo(); // expected-error {{statement in 'omp parallel sections' directive must be enclosed into a section region}}28 }29 30}31 32void test_branch_protected_scope(void) {33 int i = 0;34L1:35 ++i;36 37 int x[24];38 39#pragma omp parallel sections40 {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#pragma omp section52 if (i == 5)53 goto L1;54 else if (i == 6)55 return; // expected-error {{cannot return from OpenMP region}}56 else if (i == 7)57 goto L3;58 else if (i == 8) {59 L3:60 x[i]++;61 }62 }63 64 if (x[0] == 0)65 goto L2; // expected-error {{use of undeclared label 'L2'}}66 else if (x[1] == 1)67 goto L1;68 goto L3; // expected-error {{use of undeclared label 'L3'}}69}70 71void test_invalid_clause(void) {72 int i;73// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}74#pragma omp parallel sections foo bar75 {76 foo();77// expected-error@+1 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp section'}}78#pragma omp section nowait79 ;80 }81}82 83void test_non_identifiers(void) {84 int i, x;85 86// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}87#pragma omp parallel sections;88 {89 foo();90 }91// expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}}92// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}93#pragma omp parallel sections linear(x);94 {95 foo();96 }97 98// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}99#pragma omp parallel sections private(x);100 {101 foo();102 }103 104// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}105#pragma omp parallel sections, private(x);106 {107 foo();108 }109}110 111void test_private(void) {112 int i;113// expected-error@+2 {{expected expression}}114// expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}115#pragma omp parallel sections private(116 {117 foo();118 }119// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}120// expected-error@+1 2 {{expected expression}}121#pragma omp parallel sections private(,122 {123 foo();124 }125// expected-error@+1 2 {{expected expression}}126#pragma omp parallel sections private(, )127 {128 foo();129 }130// expected-error@+1 {{expected expression}}131#pragma omp parallel sections private()132 {133 foo();134 }135// expected-error@+1 {{expected expression}}136#pragma omp parallel sections private(int)137 {138 foo();139 }140// expected-error@+1 {{expected variable name}}141#pragma omp parallel sections private(0)142 {143 foo();144 }145 146 int x, y, z;147#pragma omp parallel sections private(x)148 {149 foo();150 }151#pragma omp parallel sections private(x, y)152 {153 foo();154 }155#pragma omp parallel sections private(x, y, z)156 {157 foo();158 }159}160 161void test_lastprivate(void) {162 int i;163// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}164// expected-error@+1 {{expected expression}}165#pragma omp parallel sections lastprivate(166 {167 foo();168 }169 170// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}171// expected-error@+1 2 {{expected expression}}172#pragma omp parallel sections lastprivate(,173 {174 foo();175 }176// expected-error@+1 2 {{expected expression}}177#pragma omp parallel sections lastprivate(, )178 {179 foo();180 }181// expected-error@+1 {{expected expression}}182#pragma omp parallel sections lastprivate()183 {184 foo();185 }186// expected-error@+1 {{expected expression}}187#pragma omp parallel sections lastprivate(int)188 {189 foo();190 }191// expected-error@+1 {{expected variable name}}192#pragma omp parallel sections lastprivate(0)193 {194 foo();195 }196 197 int x, y, z;198#pragma omp parallel sections lastprivate(x)199 {200 foo();201 }202#pragma omp parallel sections lastprivate(x, y)203 {204 foo();205 }206#pragma omp parallel sections lastprivate(x, y, z)207 {208 foo();209 }210}211 212void test_firstprivate(void) {213 int i;214// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}215// expected-error@+1 {{expected expression}}216#pragma omp parallel sections firstprivate(217 {218 foo();219 }220 221// expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}222// expected-error@+1 2 {{expected expression}}223#pragma omp parallel sections firstprivate(,224 {225 foo();226 }227// expected-error@+1 2 {{expected expression}}228#pragma omp parallel sections firstprivate(, )229 {230 foo();231 }232// expected-error@+1 {{expected expression}}233#pragma omp parallel sections firstprivate()234 {235 foo();236 }237// expected-error@+1 {{expected expression}}238#pragma omp parallel sections firstprivate(int)239 {240 foo();241 }242// expected-error@+1 {{expected variable name}}243#pragma omp parallel sections firstprivate(0)244 {245 foo();246 }247 248 int x, y, z;249#pragma omp parallel sections lastprivate(x) firstprivate(x)250 {251 foo();252 }253#pragma omp parallel sections lastprivate(x, y) firstprivate(x, y)254 {255 foo();256 }257#pragma omp parallel sections lastprivate(x, y, z) firstprivate(x, y, z)258 {259 foo();260 }261}262 263