1// Test that virtual functions of the derived class can be called through
2// pointers of both base classes without CFI errors.
3// Related to Bugzilla 43390.
4
5// RUN: %clangxx_cfi -o %t1 %s
6// RUN: %run %t1 2>&1 | FileCheck --check-prefix=CFI %s
7
8// CFI: In f1
9// CFI: In f2
10// CFI-NOT: control flow integrity check
11
12// REQUIRES: cxxabi
13
14#include <stdio.h>
15
16class A1 {
17public:
18 virtual void f1() = 0;
19};
20
21class A2 {
22public:
23 virtual void f2() = 0;
24};
25
26
27class B : public A1, public A2 {
28public:
29 void f2() final { fprintf(stderr, "In f2\n"); }
30 void f1() final { fprintf(stderr, "In f1\n"); }
31};
32
33int main() {
34 B b;
35
36 static_cast<A1*>(&b)->f1();
37 static_cast<A2*>(&b)->f2();
38}
39