aec17bfe91
PR c/63326 * c-parser.c (c_parser_compound_statement_nostart): If last_label is true, use pragma_stmt instead of pragma_compound as second c_parser_pragma argument. (c_parser_omp_ordered, c_parser_omp_target_update, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Pass false as second argument to c_parser_skip_to_pragma_eol after diagnosing standalone directives used in pragma_stmt context. * parser.c (cp_parser_statement): Clear in_compound after labels. * gcc.dg/gomp/barrier-2.c (f2): Expect another error after label. * c-c++-common/gomp/pr63326.c: New test. * testsuite/libgomp.c/cancel-parallel-2.c (foo): Add semicolon in between case label and OpenMP standalone directives. * testsuite/libgomp.c++/cancel-parallel-2.C (foo): Likewise. From-SVN: r230999
54 lines
881 B
C
54 lines
881 B
C
/* { dg-do run } */
|
|
/* { dg-set-target-env-var OMP_CANCELLATION "true" } */
|
|
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <omp.h>
|
|
|
|
static void
|
|
foo (int *x)
|
|
{
|
|
#pragma omp parallel firstprivate(x) num_threads (32)
|
|
{
|
|
int thr = omp_get_thread_num ();
|
|
switch (x[thr])
|
|
{
|
|
case 4:;
|
|
#pragma omp cancel parallel
|
|
break;
|
|
case 3:
|
|
#pragma omp task
|
|
usleep (1000);
|
|
#pragma omp task
|
|
usleep (2000);
|
|
#pragma omp task
|
|
usleep (4000);
|
|
break;
|
|
case 2:
|
|
usleep (1000);
|
|
/* FALLTHRU */
|
|
case 1:;
|
|
#pragma omp cancellation point parallel
|
|
break;
|
|
}
|
|
#pragma omp barrier
|
|
if (omp_get_cancellation ())
|
|
abort ();
|
|
}
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int i, j, x[32] = { 0, 1, 2, 4, 2, 2, 1, 0 };
|
|
foo (x);
|
|
for (i = 0; i < 32; i++)
|
|
{
|
|
for (j = 0; j < 32; j++)
|
|
x[j] = rand () & 3;
|
|
x[rand () & 31] = 4;
|
|
foo (x);
|
|
}
|
|
return 0;
|
|
}
|