+2012-06-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/53580
+ * omp-low.c (scan_omp): Change first argument to
+ gimple_seq *, call walk_gimple_seq_mod instead of
+ walk_gimple_seq.
+ (scan_sharing_clauses, scan_omp_parallel, scan_omp_task,
+ scan_omp_for, scan_omp_sections, scan_omp_single,
+ execute_lower_omp): Adjust callers.
+ (scan_omp_1_stmt): Likewise. If check_omp_nesting_restrictions
+ returns false, replace stmt with GIMPLE_NOP.
+ (check_omp_nesting_restrictions): Instead of issuing warnings,
+ issue errors and return false if any errors were reported.
+
2012-06-06 Steven Bosscher <steven@gcc.gnu.org>
* doc/invoke.texi (fconserve-space): Remove documentation.
struct omp_region *root_omp_region;
static bitmap task_shared_vars;
-static void scan_omp (gimple_seq, omp_context *);
+static void scan_omp (gimple_seq *, omp_context *);
static tree scan_omp_1_op (tree *, int *, void *);
#define WALK_SUBSTMTS \
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
&& OMP_CLAUSE_REDUCTION_PLACEHOLDER (c))
{
- scan_omp (OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
- scan_omp (OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
+ scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx);
+ scan_omp (&OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx);
}
else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE
&& OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c))
- scan_omp (OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
+ scan_omp (&OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c), ctx);
}
/* Create a new name for omp child function. Returns an identifier. */
gimple_omp_parallel_set_child_fn (stmt, ctx->cb.dst_fn);
scan_sharing_clauses (gimple_omp_parallel_clauses (stmt), ctx);
- scan_omp (gimple_omp_body (stmt), ctx);
+ scan_omp (gimple_omp_body_ptr (stmt), ctx);
if (TYPE_FIELDS (ctx->record_type) == NULL)
ctx->record_type = ctx->receiver_decl = NULL;
create_omp_child_function (ctx, true);
}
- scan_omp (gimple_omp_body (stmt), ctx);
+ scan_omp (gimple_omp_body_ptr (stmt), ctx);
if (TYPE_FIELDS (ctx->record_type) == NULL)
{
scan_sharing_clauses (gimple_omp_for_clauses (stmt), ctx);
- scan_omp (gimple_omp_for_pre_body (stmt), ctx);
+ scan_omp (gimple_omp_for_pre_body_ptr (stmt), ctx);
for (i = 0; i < gimple_omp_for_collapse (stmt); i++)
{
scan_omp_op (gimple_omp_for_index_ptr (stmt, i), ctx);
scan_omp_op (gimple_omp_for_final_ptr (stmt, i), ctx);
scan_omp_op (gimple_omp_for_incr_ptr (stmt, i), ctx);
}
- scan_omp (gimple_omp_body (stmt), ctx);
+ scan_omp (gimple_omp_body_ptr (stmt), ctx);
}
/* Scan an OpenMP sections directive. */
ctx = new_omp_context (stmt, outer_ctx);
scan_sharing_clauses (gimple_omp_sections_clauses (stmt), ctx);
- scan_omp (gimple_omp_body (stmt), ctx);
+ scan_omp (gimple_omp_body_ptr (stmt), ctx);
}
/* Scan an OpenMP single directive. */
TYPE_NAME (ctx->record_type) = name;
scan_sharing_clauses (gimple_omp_single_clauses (stmt), ctx);
- scan_omp (gimple_omp_body (stmt), ctx);
+ scan_omp (gimple_omp_body_ptr (stmt), ctx);
if (TYPE_FIELDS (ctx->record_type) == NULL)
ctx->record_type = NULL;
/* Check OpenMP nesting restrictions. */
-static void
-check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
+static bool
+check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
{
switch (gimple_code (stmt))
{
case GIMPLE_OMP_TASK:
if (is_gimple_call (stmt))
{
- warning (0, "barrier region may not be closely nested inside "
- "of work-sharing, critical, ordered, master or "
- "explicit task region");
- return;
+ error_at (gimple_location (stmt),
+ "barrier region may not be closely nested inside "
+ "of work-sharing, critical, ordered, master or "
+ "explicit task region");
+ return false;
}
- warning (0, "work-sharing region may not be closely nested inside "
- "of work-sharing, critical, ordered, master or explicit "
- "task region");
- return;
+ error_at (gimple_location (stmt),
+ "work-sharing region may not be closely nested inside "
+ "of work-sharing, critical, ordered, master or explicit "
+ "task region");
+ return false;
case GIMPLE_OMP_PARALLEL:
- return;
+ return true;
default:
break;
}
case GIMPLE_OMP_SECTIONS:
case GIMPLE_OMP_SINGLE:
case GIMPLE_OMP_TASK:
- warning (0, "master region may not be closely nested inside "
- "of work-sharing or explicit task region");
- return;
+ error_at (gimple_location (stmt),
+ "master region may not be closely nested inside "
+ "of work-sharing or explicit task region");
+ return false;
case GIMPLE_OMP_PARALLEL:
- return;
+ return true;
default:
break;
}
{
case GIMPLE_OMP_CRITICAL:
case GIMPLE_OMP_TASK:
- warning (0, "ordered region may not be closely nested inside "
- "of critical or explicit task region");
- return;
+ error_at (gimple_location (stmt),
+ "ordered region may not be closely nested inside "
+ "of critical or explicit task region");
+ return false;
case GIMPLE_OMP_FOR:
if (find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
OMP_CLAUSE_ORDERED) == NULL)
- warning (0, "ordered region must be closely nested inside "
+ {
+ error_at (gimple_location (stmt),
+ "ordered region must be closely nested inside "
"a loop region with an ordered clause");
- return;
+ return false;
+ }
+ return true;
case GIMPLE_OMP_PARALLEL:
- return;
+ return true;
default:
break;
}
&& (gimple_omp_critical_name (stmt)
== gimple_omp_critical_name (ctx->stmt)))
{
- warning (0, "critical region may not be nested inside a critical "
- "region with the same name");
- return;
+ error_at (gimple_location (stmt),
+ "critical region may not be nested inside a critical "
+ "region with the same name");
+ return false;
}
break;
default:
break;
}
+ return true;
}
/* Check the OpenMP nesting restrictions. */
if (ctx != NULL)
{
+ bool remove = false;
if (is_gimple_omp (stmt))
- check_omp_nesting_restrictions (stmt, ctx);
+ remove = !check_omp_nesting_restrictions (stmt, ctx);
else if (is_gimple_call (stmt))
{
tree fndecl = gimple_call_fndecl (stmt);
if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_GOMP_BARRIER)
- check_omp_nesting_restrictions (stmt, ctx);
+ remove = !check_omp_nesting_restrictions (stmt, ctx);
+ }
+ if (remove)
+ {
+ stmt = gimple_build_nop ();
+ gsi_replace (gsi, stmt, false);
}
}
case GIMPLE_OMP_ORDERED:
case GIMPLE_OMP_CRITICAL:
ctx = new_omp_context (stmt, ctx);
- scan_omp (gimple_omp_body (stmt), ctx);
+ scan_omp (gimple_omp_body_ptr (stmt), ctx);
break;
case GIMPLE_BIND:
clauses found during the scan. */
static void
-scan_omp (gimple_seq body, omp_context *ctx)
+scan_omp (gimple_seq *body_p, omp_context *ctx)
{
location_t saved_location;
struct walk_stmt_info wi;
wi.want_locations = true;
saved_location = input_location;
- walk_gimple_seq (body, scan_omp_1_stmt, scan_omp_1_op, &wi);
+ walk_gimple_seq_mod (body_p, scan_omp_1_stmt, scan_omp_1_op, &wi);
input_location = saved_location;
}
\f
delete_omp_context);
body = gimple_body (current_function_decl);
- scan_omp (body, NULL);
+ scan_omp (&body, NULL);
gcc_assert (taskreg_nesting_level == 0);
if (all_contexts->root)
+2012-06-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/53580
+ * gcc.dg/gomp/nesting-1.c: Expect errors rather than warnings.
+ * gcc.dg/gomp/critical-4.c: Likewise.
+ * gfortran.dg/gomp/appendix-a/a.35.1.f90: Likewise.
+ * gfortran.dg/gomp/appendix-a/a.35.3.f90: Likewise.
+ * gfortran.dg/gomp/appendix-a/a.35.4.f90: Likewise.
+ * gfortran.dg/gomp/appendix-a/a.35.6.f90: Likewise.
+ * c-c++-common/gomp/pr53580.c: New test.
+
2012-06-07 Fabien ChĂȘne <fabien@gcc.gnu.org>
PR c++/51214
--- /dev/null
+/* PR middle-end/53580 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int
+main ()
+{
+ int x, y, v = 0;
+
+#pragma omp parallel
+ #pragma omp for
+ for (x = 0; x < 10; x++)
+ {
+ #pragma omp for reduction(+: v) /* { dg-error "work-sharing region may not be closely nested inside of work-sharing" } */
+ for (y = 0; y < 10; y++)
+ v++;
+ }
+ return v - 100;
+}
foo2 (void)
{
#pragma omp critical
- #pragma omp critical /* { dg-warning "with the same name" } */
+ #pragma omp critical /* { dg-error "with the same name" } */
bar (0);
}
foo3 (void)
{
#pragma omp critical(foo)
- #pragma omp critical(foo) /* { dg-warning "with the same name" } */
+ #pragma omp critical(foo) /* { dg-error "with the same name" } */
bar (0);
}
#pragma omp for
for (i = 0; i < 3; i++)
{
- #pragma omp for /* { dg-warning "may not be closely nested" } */
+ #pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
- #pragma omp sections /* { dg-warning "may not be closely nested" } */
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
- #pragma omp single /* { dg-warning "may not be closely nested" } */
+ #pragma omp single /* { dg-error "may not be closely nested" } */
;
- #pragma omp master /* { dg-warning "may not be closely nested" } */
+ #pragma omp master /* { dg-error "may not be closely nested" } */
;
- #pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ #pragma omp barrier /* { dg-error "may not be closely nested" } */
}
#pragma omp sections
{
- #pragma omp for /* { dg-warning "may not be closely nested" } */
+ #pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
- #pragma omp sections /* { dg-warning "may not be closely nested" } */
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
- #pragma omp single /* { dg-warning "may not be closely nested" } */
+ #pragma omp single /* { dg-error "may not be closely nested" } */
;
- #pragma omp master /* { dg-warning "may not be closely nested" } */
+ #pragma omp master /* { dg-error "may not be closely nested" } */
;
#pragma omp section
;
}
#pragma omp single
{
- #pragma omp for /* { dg-warning "may not be closely nested" } */
+ #pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
- #pragma omp sections /* { dg-warning "may not be closely nested" } */
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
- #pragma omp single /* { dg-warning "may not be closely nested" } */
+ #pragma omp single /* { dg-error "may not be closely nested" } */
;
- #pragma omp master /* { dg-warning "may not be closely nested" } */
+ #pragma omp master /* { dg-error "may not be closely nested" } */
;
- #pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ #pragma omp barrier /* { dg-error "may not be closely nested" } */
}
#pragma omp master
{
- #pragma omp for /* { dg-warning "may not be closely nested" } */
+ #pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
- #pragma omp sections /* { dg-warning "may not be closely nested" } */
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
- #pragma omp single /* { dg-warning "may not be closely nested" } */
+ #pragma omp single /* { dg-error "may not be closely nested" } */
;
#pragma omp master
;
- #pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ #pragma omp barrier /* { dg-error "may not be closely nested" } */
}
#pragma omp task
{
- #pragma omp for /* { dg-warning "may not be closely nested" } */
+ #pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
- #pragma omp sections /* { dg-warning "may not be closely nested" } */
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
- #pragma omp single /* { dg-warning "may not be closely nested" } */
+ #pragma omp single /* { dg-error "may not be closely nested" } */
;
- #pragma omp master /* { dg-warning "may not be closely nested" } */
+ #pragma omp master /* { dg-error "may not be closely nested" } */
;
- #pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ #pragma omp barrier /* { dg-error "may not be closely nested" } */
}
#pragma omp parallel
{
int i, j;
#pragma omp ordered
{
- #pragma omp for /* { dg-warning "may not be closely nested" } */
+ #pragma omp for /* { dg-error "may not be closely nested" } */
for (j = 0; j < 3; j++)
;
- #pragma omp sections /* { dg-warning "may not be closely nested" } */
+ #pragma omp sections /* { dg-error "may not be closely nested" } */
{
;
#pragma omp section
;
}
- #pragma omp single /* { dg-warning "may not be closely nested" } */
+ #pragma omp single /* { dg-error "may not be closely nested" } */
;
#pragma omp master
;
- #pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ #pragma omp barrier /* { dg-error "may not be closely nested" } */
}
}
{
#pragma omp critical
{
- #pragma omp ordered /* { dg-warning "may not be closely nested" } */
+ #pragma omp ordered /* { dg-error "may not be closely nested" } */
;
}
}
{
#pragma omp task
{
- #pragma omp ordered /* { dg-warning "may not be closely nested" } */
+ #pragma omp ordered /* { dg-error "may not be closely nested" } */
;
}
}
#pragma omp for
for (i = 0; i < 10; i++)
{
- #pragma omp ordered /* { dg-warning "must be closely nested" } */
+ #pragma omp ordered /* { dg-error "must be closely nested" } */
;
}
#pragma omp for ordered
#pragma omp critical
;
#pragma omp critical (bar)
- #pragma omp critical (bar) /* { dg-warning "may not be nested" } */
+ #pragma omp critical (bar) /* { dg-error "may not be nested" } */
;
#pragma omp critical
- #pragma omp critical /* { dg-warning "may not be nested" } */
+ #pragma omp critical /* { dg-error "may not be nested" } */
;
}
!$OMP DO
DO I = 1, N
! incorrect nesting of loop regions
-!$OMP DO ! { dg-warning "may not be closely nested" }
+!$OMP DO ! { dg-error "may not be closely nested" }
DO J = 1, N
CALL WORK(I,J)
END DO
!$OMP DO
DO I = 1, N
! incorrect nesting of regions
-!$OMP SINGLE ! { dg-warning "may not be closely nested" }
+!$OMP SINGLE ! { dg-error "may not be closely nested" }
CALL WORK(I, 1)
!$OMP END SINGLE
END DO
DO I = 1, N
CALL WORK(I, 1)
! incorrect nesting of barrier region in a loop region
-!$OMP BARRIER ! { dg-warning "may not be closely nested" }
+!$OMP BARRIER ! { dg-error "may not be closely nested" }
CALL WORK(I, 2)
END DO
!$OMP END PARALLEL
!$OMP SINGLE
CALL WORK(N,1)
! incorrect nesting of barrier region in a single region
-!$OMP BARRIER ! { dg-warning "may not be closely nested" }
+!$OMP BARRIER ! { dg-error "may not be closely nested" }
CALL WORK(N,2)
!$OMP END SINGLE
!$OMP END PARALLEL
+2012-06-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/53580
+ * testsuite/libgomp.c/pr26943-2.c: Remove #pragma omp barrier,
+ use GOMP_barrier () call instead.
+ * testsuite/libgomp.c/pr26943-3.c: Likewise.
+ * testsuite/libgomp.c/pr26943-4.c: Likewise.
+ * testsuite/libgomp.fortran/vla4.f90: Remove !$omp barrier,
+ call GOMP_barrier instead.
+ * testsuite/libgomp.fortran/vla5.f90: Likewise.
+
2012-06-06 Jakub Jelinek <jakub@redhat.com>
PR libgomp/52993
extern int omp_set_dynamic (int);
extern void abort (void);
+extern void GOMP_barrier (void);
int a = 8, b = 12, c = 16, d = 20, j = 0;
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
{
if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
j++;
-#pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ GOMP_barrier ();
#pragma omp atomic
a += i;
b += i;
f[0] += i;
g[0] = 'g' + i;
h[0] = 'h' + i;
-#pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ GOMP_barrier ();
if (a != 8 + 6 || b != 12 + i || c != i || d != i)
j += 8;
if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
extern int omp_set_dynamic (int);
extern int omp_get_thread_num (void);
extern void abort (void);
+extern void GOMP_barrier (void);
int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
{
if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
j++;
-#pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ GOMP_barrier ();
#pragma omp atomic
a += i;
b += i;
f[0] += i;
g[0] = 'g' + i;
h[0] = 'h' + i;
-#pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ GOMP_barrier ();
if (a != 8 + 6 || b != 12 + i || c != i || d != i)
j += 8;
if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
extern int omp_set_dynamic (int);
extern int omp_get_thread_num (void);
extern void abort (void);
+extern void GOMP_barrier (void);
int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
{
if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
j++;
-#pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ GOMP_barrier ();
#pragma omp atomic
a += i;
b += i;
f[0] += i;
g[0] = 'g' + i;
h[0] = 'h' + i;
-#pragma omp barrier /* { dg-warning "may not be closely nested" } */
+ GOMP_barrier ();
if (a != 8 + 6 || b != 12 + i || c != i || d != i)
j += 8;
if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
subroutine foo (c, d, e, f, g, h, i, j, k, n)
use omp_lib
+ interface
+ subroutine GOMP_barrier () bind(c, name="GOMP_barrier")
+ end subroutine
+ end interface
integer :: n
character (len = *) :: c
character (len = n) :: d
forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r
forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7)
forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26)
-!$omp barrier ! { dg-warning "may not be closely nested" }
+ call GOMP_barrier
y = ''
if (x .eq. 0) y = '0'
if (x .eq. 1) y = '1'
subroutine foo (c, d, e, f, g, h, i, j, k, n)
use omp_lib
+ interface
+ subroutine GOMP_barrier () bind(c, name="GOMP_barrier")
+ end subroutine
+ end interface
integer :: n
character (len = *) :: c
character (len = n) :: d
forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r
forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7)
forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26)
-!$omp barrier ! { dg-warning "may not be closely nested" }
+ call GOMP_barrier
y = ''
if (x .eq. 0) y = '0'
if (x .eq. 1) y = '1'