Debian Codegraph @

libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C

raw
1 /* 'std::bad_cast' exception in OpenACC compute region, dead code. */
2
3 /* { dg-require-effective-target exceptions }
4 { dg-additional-options -fexceptions } */
5 /* Wrong code for offloading execution.
6 { dg-skip-if PR119692 { ! openacc_host_selected } }
7 { dg-additional-options -fdump-tree-gimple } */
8 /* { dg-additional-options -fdump-tree-optimized-raw } */
9
10 /* See also '../libgomp.c++/target-exceptions-bad_cast-3.C'. */
11
12 /* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-bad_cast-3.C',
13 '../../../gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-3.C'. */
14
15 /* For PR119692 workarounds. */
16 #ifndef DEFAULT
17 # define DEFAULT
18 #endif
19
20 struct C1
21 {
22 virtual void f()
23 {}
24 };
25
26 struct C2 : C1
27 {
28 };
29
30 int main()
31 {
32 #pragma omp target DEFAULT
33 #pragma acc serial DEFAULT
34 {
35 C1 c1;
36 bool a = false;
37 asm volatile ("" : : "r" (&a) : "memory");
38 if (a)
39 {
40 [[maybe_unused]]
41 C2 &c2 = dynamic_cast<C2 &>(c1);
42 /* 'std::bad_cast' is thrown. */
43 }
44 }
45 }
46
47 /* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial map\(tofrom:_ZTI2C2 \[len: [0-9]+\]\) map\(tofrom:_ZTI2C1 \[len: [0-9]+\]\) map\(tofrom:_ZTV2C1 \[len: [0-9]+\]\)$} gimple { xfail *-*-* } } } */
48
49 /* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 optimized } } */