https://github.com/jtb20 created https://github.com/llvm/llvm-project/pull/200407
Per OpenMP 6.0 [7.2], the 'saved' modifier on a data-environment attribute clause has effect only when that clause appears on a replayable construct. Per [14.3] and [14.6], the only directives that admit the 'replayable' clause are: 'target', 'target enter data', 'target exit data', 'target update', 'task', 'taskloop' and 'taskwait'. Of those seven, only 'target', 'task' and 'taskloop' also admit a 'firstprivate' clause; the remaining four cannot syntactically carry 'firstprivate' and need no extra sema work. A directive outside the admitted set can never make 'firstprivate(saved: ...)' meaningful. We do not try to flag every dead-modifier case statically: 'saved' on a directive in the admitted set but without 'replayable' (and without lexical nesting in a taskgraph) is well-formed per [7.2] and silently has no effect. Detecting that would require inspecting the full clause list, and is invalidated as soon as the user adds the clause or moves the construct inside a taskgraph. What we can and do diagnose is the case where the host directive itself cannot ever be a replayable construct: 'saved' on a 'parallel', 'for', 'sections', 'single', 'distribute', 'teams', etc. firstprivate clause has no path to replay semantics at all. Reject that in ActOnOpenMPFirstprivateClause when CurDir is neither an OpenMP tasking directive (isOpenMPTaskingDirective, which covers OMPD_task and every OMPD_*taskloop* variant) nor an OpenMP target execution directive (isOpenMPTargetExecutionDirective, which covers OMPD_target and every combined directive that has OMPD_target as a leaf construct), with a new dedicated diagnostic err_omp_firstprivate_saved_wrong_directive that points at the modifier location and lists the three admissible directives. The existing ast-print test is extended to cover these cases, and other new tests have been added. Assisted-By: Claude Opus 4.7 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
