On Tue, Dec 08, 2020 at 01:13:07PM +0100, Tobias Burnus wrote: > + if (list == OMP_LIST_REDUCTION) > + has_inscan = true;
This looks weird, I would have expected if (list == OMP_LIST_REDUCTION_INSCAN) > @@ -6151,6 +6203,28 @@ gfc_resolve_omp_do_blocks (gfc_code *code, > gfc_namespace *ns) > } > if (i < omp_current_do_collapse || omp_current_do_collapse <= 0) > omp_current_do_collapse = 1; > + if (code->ext.omp_clauses->lists[OMP_LIST_REDUCTION_INSCAN]) > + { > + locus *loc > + = &code->ext.omp_clauses->lists[OMP_LIST_REDUCTION_INSCAN]->where; > + if (code->ext.omp_clauses->ordered) > + gfc_error ("ORDERED clause specified together with %<inscan%> " > + "REDUCTION clause at %L", loc); > + if (code->ext.omp_clauses->sched_kind != OMP_SCHED_NONE) > + gfc_error ("SCHEDULE clause specified together with %<inscan%> " > + "REDUCTION clause at %L", loc); > + if (!c->block > + || !c->block->next > + || !c->block->next->next > + || c->block->next->next->op != EXEC_OMP_SCAN > + || !c->block->next->next->next > + || c->block->next->next->next->next) > + gfc_error ("With INSCAN at %L, expected loop body with !$OMP SCAN " > + "between two structured-block-sequences", loc); > + else > + /* Mark as checked; flag will be unset later. */ > + c->block->next->next->ext.omp_clauses->if_present = true; > + } So you initially accept !$omp scan everywhere and only later complain if it is misplaced? I think e.g. for !$omp section I used to hardcode it in parse_omp_structured_block - allow it only there and nowhere else: else if (st == ST_OMP_SECTION && (omp_st == ST_OMP_SECTIONS || omp_st == ST_OMP_PARALLEL_SECTIONS)) > @@ -7046,6 +7122,14 @@ gfc_resolve_omp_directive (gfc_code *code, > gfc_namespace *ns ATTRIBUTE_UNUSED) > gfc_error ("OMP CRITICAL at %L with HINT clause requires a NAME, " > "except when omp_sync_hint_none is used", &code->loc); > break; > + case EXEC_OMP_SCAN: > + /* Flag is only used to checking, hence, it is unset afterwards. */ > + if (!code->ext.omp_clauses->if_present) Isn't if_present used also for OpenACC? Then can't it with -fopenmp -fopenacc allow !$acc ... if_present... !$omp scan inclusive(...) !$add end ... ? > + gfc_error ("Unexpected !$OMP SCAN at %L outside loop construct with " > + "%<inscan%> REDUCTION clause", &code->loc); > + code->ext.omp_clauses->if_present = false; > + resolve_omp_clauses (code, code->ext.omp_clauses, ns); > + break; > default: > break; > } Otherwise LGTM. Jakub