xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/virtual-function-calls.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 %s -triple %itanium_abi_triple -std=c++11 -emit-llvm -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc // PR5021
4f4a2713aSLionel Sambuc namespace PR5021 {
5f4a2713aSLionel Sambuc 
6f4a2713aSLionel Sambuc struct A {
7f4a2713aSLionel Sambuc   virtual void f(char);
8f4a2713aSLionel Sambuc };
9f4a2713aSLionel Sambuc 
f(A * a)10f4a2713aSLionel Sambuc void f(A *a) {
11*0a6a1f1dSLionel Sambuc   // CHECK: call {{.*}}void %
12f4a2713aSLionel Sambuc   a->f('c');
13f4a2713aSLionel Sambuc }
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc struct B : virtual A {
16f4a2713aSLionel Sambuc   virtual void f();
17f4a2713aSLionel Sambuc };
18f4a2713aSLionel Sambuc 
f(B * b)19f4a2713aSLionel Sambuc void f(B * b) {
20f4a2713aSLionel Sambuc   b->f();
21f4a2713aSLionel Sambuc }
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc }
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc namespace Test1 {
26f4a2713aSLionel Sambuc   struct A {
27f4a2713aSLionel Sambuc     virtual ~A();
28f4a2713aSLionel Sambuc   };
29f4a2713aSLionel Sambuc 
30f4a2713aSLionel Sambuc   struct B : A {
31f4a2713aSLionel Sambuc     virtual ~B();
32f4a2713aSLionel Sambuc     virtual void f();
33f4a2713aSLionel Sambuc   };
34f4a2713aSLionel Sambuc 
f(B * b)35f4a2713aSLionel Sambuc   void f(B *b) {
36f4a2713aSLionel Sambuc     b->f();
37f4a2713aSLionel Sambuc   }
38f4a2713aSLionel Sambuc }
39f4a2713aSLionel Sambuc 
40f4a2713aSLionel Sambuc namespace VirtualNoreturn {
41f4a2713aSLionel Sambuc   struct A {
42f4a2713aSLionel Sambuc     [[noreturn]] virtual void f();
43f4a2713aSLionel Sambuc   };
44f4a2713aSLionel Sambuc 
45f4a2713aSLionel Sambuc   // CHECK: @_ZN15VirtualNoreturn1f
f(A * p)46f4a2713aSLionel Sambuc   void f(A *p) {
47f4a2713aSLionel Sambuc     p->f();
48*0a6a1f1dSLionel Sambuc     // CHECK: call {{.*}}void %{{[^#]*$}}
49f4a2713aSLionel Sambuc     // CHECK-NOT: unreachable
50f4a2713aSLionel Sambuc   }
51f4a2713aSLionel Sambuc }
52