48 lines · cpp
1// REQUIRES: nvptx-registered-target, staticanalyzer2 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 the7 * target region but emit a warning instead.8*/9 10// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=with -Wopenmp-target-exception -analyze11// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=with -Wopenmp-target-exception -analyze12// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -verify=with -Wopenmp-target-exception -analyze13// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -verify=with -Wopenmp-target-exception -analyze14 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.19*/20 21// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -verify=without -Wno-openmp-target-exception -analyze22// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions %s -verify=without -Wno-openmp-target-exception -analyze23// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -verify=without -Wno-openmp-target-exception -analyze24// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -verify=without -Wno-openmp-target-exception -analyze25 26/**27 * Finally we should test that we only ignore exceptions in the OpenMP 28 * offloading tool-chain29*/30 31// RUN: %clang_cc1 -triple nvptx64 %s -emit-llvm-only -verify=noexceptions32 33// noexceptions-error@38 {{cannot use 'try' with exceptions disabled}}34 35#pragma omp declare target36int foo(void) {37 int error = -1;38 try { // with-warning {{target 'nvptx64' does not support exception handling; 'catch' block is ignored}}39 error = 1;40 }41 catch (int e){ 42 error = e;43 }44 return error;45}46#pragma omp end declare target47// without-no-diagnostics48