mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
Follow-up to #220702. Completes #204240. The device runtime accepted the `ident_t` argument but ignored it, so `error at(execution)` in a `target` region printed no source location. This reports it, replicating the host runtime: ``` OMP: error_directive.f90:14:3: Encountered user-directed warning: warning message. ``` When the ident carries no location the result is `unknown:0:0`, same as the host. flang populates the ident only with `-g`; clang always does. Assisted-by: Copilot
41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
// Test the `error` directive with `at(execution)` inside a target region.
|
|
//
|
|
// REQUIRES: libc
|
|
|
|
// RUN: %libomptarget-compile-generic -fopenmp-version=51 && \
|
|
// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
|
|
// RUN: %libomptarget-compile-generic -fopenmp-version=51 -DFATAL && \
|
|
// RUN: %libomptarget-run-fail-generic
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
#ifdef FATAL
|
|
#pragma omp target
|
|
{
|
|
#pragma omp error at(execution) severity(fatal) message("fatal message")
|
|
}
|
|
printf("unreachable\n");
|
|
#else
|
|
#pragma omp target
|
|
{
|
|
// CHECK: {{.*}}error_directive.c:[[# @LINE + 1]]:{{[0-9]+}}: Encountered user-directed warning: warning message.
|
|
#pragma omp error at(execution) severity(warning) message("warning message")
|
|
}
|
|
|
|
// No MESSAGE clause, so the runtime receives a null message pointer.
|
|
#pragma omp target
|
|
{
|
|
// CHECK: {{.*}}error_directive.c:[[# @LINE + 1]]:{{[0-9]+}}: Encountered user-directed warning.
|
|
#pragma omp error at(execution) severity(warning)
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
// Device output is flushed after host output, so host prints are not checked.
|
|
// The fatal case checks only the exit status: its message is lost when the trap
|
|
// aborts before the buffered stdout is flushed.
|
|
//
|
|
// clang fills in the ident location from the AST, so it is present without -g
|