11968f0d7SHans Wennborg // REQUIRES: amdgpu-registered-target, staticanalyzer
23c9988f8SAnton Rydahl
33c9988f8SAnton Rydahl /**
43c9988f8SAnton Rydahl * The first four lines test that a warning is produced when enabling
53c9988f8SAnton Rydahl * -Wopenmp-target-exception no matter what combination of -fexceptions and
63c9988f8SAnton Rydahl * -fcxx-exceptions are set, as we want OpenMP to always allow exceptions in the
73c9988f8SAnton Rydahl * target region but emit a warning instead.
83c9988f8SAnton Rydahl */
93c9988f8SAnton Rydahl
10*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=with -Wopenmp-target-exception -analyze
11*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=with -Wopenmp-target-exception -analyze
12*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fexceptions %s -verify=with -Wopenmp-target-exception -analyze
13*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device %s -verify=with -Wopenmp-target-exception -analyze
143c9988f8SAnton Rydahl
153c9988f8SAnton Rydahl /**
163c9988f8SAnton Rydahl * The following four lines test that no warning is emitted when providing
173c9988f8SAnton Rydahl * -Wno-openmp-target-exception no matter the combination of -fexceptions and
183c9988f8SAnton Rydahl * -fcxx-exceptions.
193c9988f8SAnton Rydahl */
203c9988f8SAnton Rydahl
21*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=without -Wno-openmp-target-exception -analyze
22*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fcxx-exceptions %s -verify=without -Wno-openmp-target-exception -analyze
23*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device -fexceptions %s -verify=without -Wno-openmp-target-exception -analyze
24*e4d24276SFangrui Song // RUN: %clang_cc1 -fopenmp -triple amdgcn-amd-amdhsa -fopenmp-is-target-device %s -verify=without -Wno-openmp-target-exception -analyze
253c9988f8SAnton Rydahl
263c9988f8SAnton Rydahl /**
273c9988f8SAnton Rydahl * Finally we should test that we only ignore exceptions in the OpenMP
283c9988f8SAnton Rydahl * offloading tool-chain
293c9988f8SAnton Rydahl */
303c9988f8SAnton Rydahl
31c4c3efa1SFangrui Song // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa %s -emit-llvm-only -verify=noexceptions
323c9988f8SAnton Rydahl
333c9988f8SAnton Rydahl // noexceptions-error@39 {{cannot use 'try' with exceptions disabled}}
343c9988f8SAnton Rydahl // noexceptions-error@40 {{cannot use 'throw' with exceptions disabled}}
353c9988f8SAnton Rydahl
363c9988f8SAnton Rydahl #pragma omp declare target
foo(void)373c9988f8SAnton Rydahl int foo(void) {
383c9988f8SAnton Rydahl int error = -1;
393c9988f8SAnton Rydahl try { // with-warning {{target 'amdgcn-amd-amdhsa' does not support exception handling; 'catch' block is ignored}}
403c9988f8SAnton Rydahl throw 404; // with-warning {{target 'amdgcn-amd-amdhsa' does not support exception handling; 'throw' is assumed to be never reached}}
413c9988f8SAnton Rydahl }
423c9988f8SAnton Rydahl catch (int e){
433c9988f8SAnton Rydahl error = e;
443c9988f8SAnton Rydahl }
453c9988f8SAnton Rydahl return error;
463c9988f8SAnton Rydahl }
473c9988f8SAnton Rydahl #pragma omp end declare target
483c9988f8SAnton Rydahl // without-no-diagnostics
49