[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / amdgpu_throw.cpp
blob84d861371a825824f0fe00a69f749088267e57f2
1 // REQUIRES: amdgpu-registered-target, staticanalyzer
3 /**
4 * The first four lines test that a warning is produced when enabling
5 * -Wopenmp-target-exception no matter what combination of -fexceptions and
6 * -fcxx-exceptions are set, as we want OpenMP to always allow exceptions in the
7 * target region but emit a warning instead.
8 */
10 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=with -Wopenmp-target-exception -analyze
11 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=with -Wopenmp-target-exception -analyze
12 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fexceptions %s -verify=with -Wopenmp-target-exception -analyze
13 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device %s -verify=with -Wopenmp-target-exception -analyze
15 /**
16 * The following four lines test that no warning is emitted when providing
17 * -Wno-openmp-target-exception no matter the combination of -fexceptions and
18 * -fcxx-exceptions.
21 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=without -Wno-openmp-target-exception -analyze
22 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions %s -verify=without -Wno-openmp-target-exception -analyze
23 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fexceptions %s -verify=without -Wno-openmp-target-exception -analyze
24 // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device %s -verify=without -Wno-openmp-target-exception -analyze
26 /**
27 * Finally we should test that we only ignore exceptions in the OpenMP
28 * offloading tool-chain
31 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa %s -emit-llvm-only -verify=noexceptions
33 // noexceptions-error@37 {{cannot use 'throw' with exceptions disabled}}
35 #pragma omp declare target
36 void foo(void) {
37 throw 404; // with-warning {{target 'amdgcn-amd-amdhsa' does not support exception handling; 'throw' is assumed to be never reached}}
39 #pragma omp end declare target
40 // without-no-diagnostics