| 1 |
/* 'throw' in OpenACC compute region. */ |
| 2 |
|
| 3 |
/* { dg-require-effective-target exceptions } |
| 4 |
{ dg-additional-options -fexceptions } */ |
| 5 |
/* { dg-additional-options -fdump-tree-optimized-raw } |
| 6 |
{ dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */ |
| 7 |
|
| 8 |
/* See also '../libgomp.c++/target-exceptions-throw-1.C'. */ |
| 9 |
|
| 10 |
/* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-throw-1.C', |
| 11 |
'../../../gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C'. */ |
| 12 |
|
| 13 |
#include <iostream> |
| 14 |
|
| 15 |
class MyException |
| 16 |
{ |
| 17 |
}; |
| 18 |
|
| 19 |
int main() |
| 20 |
{ |
| 21 |
std::cerr << "CheCKpOInT\n"; |
| 22 |
#pragma omp target |
| 23 |
#pragma acc serial |
| 24 |
/* { dg-bogus {using 'vector_length \(32\)', ignoring 1} {} { target openacc_nvidia_accel_selected xfail *-*-* } .-1 } */ |
| 25 |
{ |
| 26 |
MyException e1; |
| 27 |
throw e1; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
/* { dg-output {CheCKpOInT[\r\n]+} } |
| 32 |
|
| 33 |
{ dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } } |
| 34 |
{ dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } } |
| 35 |
{ dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } } |
| 36 |
{ dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } } |
| 37 |
For host execution, we print something like: |
| 38 |
terminate called after throwing an instance of 'MyException' |
| 39 |
Aborted (core dumped) |
| 40 |
{ dg-output {.*MyException} { target openacc_host_selected } } |
| 41 |
For GCN, nvptx offload execution, we don't print anything, but just 'abort'. |
| 42 |
|
| 43 |
{ dg-shouldfail {'MyException' exception} } */ |