template <class T>
void foo() {
+ T a = T();
// PARALLEL DIRECTIVE
#pragma omp parallel
#pragma omp for
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp parallel
+ {
+#pragma omp atomic
+ ++a;
+ }
// SIMD DIRECTIVE
#pragma omp simd
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
bar();
}
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// FOR DIRECTIVE
#pragma omp for
}
#pragma omp for
for (int i = 0; i < 10; ++i) {
-#pragma omp critical
+#pragma omp critical
{
bar();
}
#pragma omp ordered // OK
bar();
}
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+ ++a;
+ }
// SECTIONS DIRECTIVE
#pragma omp sections
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp sections
+ {
+#pragma omp atomic
+ ++a;
+ }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
bar();
}
}
+#pragma omp sections
+ {
+#pragma omp section
+#pragma omp atomic
+ ++a;
+ }
// SINGLE DIRECTIVE
#pragma omp single
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp single
+ {
+#pragma omp atomic
+ ++a;
+ }
// MASTER DIRECTIVE
#pragma omp master
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp master
+ {
+#pragma omp atomic
+ ++a;
+ }
// CRITICAL DIRECTIVE
#pragma omp critical
#pragma omp critical(grelka)
bar();
}
-#pragma omp critical(Belka)// expected-note {{previous 'critical' region starts here}}
+#pragma omp critical(Belka) // expected-note {{previous 'critical' region starts here}}
{
#pragma omp critical(Belka) // expected-error {{cannot nest 'critical' regions having the same name 'Belka'}}
{
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp critical
+ {
+#pragma omp atomic
+ ++a;
+ }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
#pragma omp ordered // OK
bar();
}
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+ ++a;
+ }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp parallel sections
+ {
+#pragma omp atomic
+ ++a;
+ }
// TASK DIRECTIVE
#pragma omp task
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp task
+ {
+#pragma omp atomic
+ ++a;
+ }
// ORDERED DIRECTIVE
#pragma omp ordered
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp ordered
+ {
+#pragma omp atomic
+ ++a;
+ }
+
+// ATOMIC DIRECTIVE
+#pragma omp atomic
+ {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ ++a;
+ }
}
void foo() {
+ int a = 0;
// PARALLEL DIRECTIVE
#pragma omp parallel
#pragma omp for
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp parallel
+ {
+#pragma omp atomic
+ ++a;
+ }
// SIMD DIRECTIVE
#pragma omp simd
#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
bar();
}
+#pragma omp simd
+ for (int i = 0; i < 10; ++i) {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
+ ++a;
+ }
// FOR DIRECTIVE
#pragma omp for
#pragma omp ordered // OK
bar();
}
+#pragma omp for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+ ++a;
+ }
// SECTIONS DIRECTIVE
#pragma omp sections
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp sections
+ {
+#pragma omp atomic
+ ++a;
+ }
// SECTION DIRECTIVE
#pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
bar();
}
}
+#pragma omp sections
+ {
+#pragma omp section
+ {
+#pragma omp atomic
+ ++a;
+ }
+ }
// SINGLE DIRECTIVE
#pragma omp single
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp single
+ {
+#pragma omp atomic
+ ++a;
+ }
// MASTER DIRECTIVE
#pragma omp master
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp master
+ {
+#pragma omp atomic
+ ++a;
+ }
// CRITICAL DIRECTIVE
#pragma omp critical
#pragma omp critical(Strelka)
bar();
}
-#pragma omp critical(Tuzik)// expected-note {{previous 'critical' region starts here}}
+#pragma omp critical(Tuzik) // expected-note {{previous 'critical' region starts here}}
{
#pragma omp critical(grelka) // expected-note {{previous 'critical' region starts here}}
{
}
#pragma omp critical
{
+#pragma omp flush
+ bar();
+ }
+#pragma omp critical
+ {
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp critical
+ {
+#pragma omp atomic
+ ++a;
+ }
// PARALLEL FOR DIRECTIVE
#pragma omp parallel for
}
#pragma omp parallel for ordered
for (int i = 0; i < 10; ++i) {
-#pragma omp ordered // OK
+#pragma omp ordered // OK
bar();
}
+#pragma omp parallel for
+ for (int i = 0; i < 10; ++i) {
+#pragma omp atomic
+ ++a;
+ }
// PARALLEL SECTIONS DIRECTIVE
#pragma omp parallel sections
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp parallel sections
+ {
+#pragma omp atomic
+ ++a;
+ }
// TASK DIRECTIVE
#pragma omp task
#pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}}
bar();
}
+#pragma omp task
+ {
+#pragma omp atomic
+ ++a;
+ }
+
+// ATOMIC DIRECTIVE
+#pragma omp atomic
+ {
+#pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ for (int i = 0; i < 10; ++i)
+ ;
+ }
+#pragma omp atomic
+ {
+#pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ {
+ bar();
+ }
+ }
+#pragma omp atomic
+ {
+#pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ bar();
+ }
+#pragma omp atomic
+ {
+#pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+ ++a;
+ }
return foo<int>();
}