blob: da08bfde957ba906772574dcd4a7aafbe0878f32 [file] [log] [blame]
Sven van Haastregt49ffffb2018-04-23 11:23:47 +00001// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -fsyntax-only -verify
2
3// Test that virtual functions and abstract classes are rejected.
4class virtual_functions {
5 virtual void bad1() {}
6 //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
7
8 virtual void bad2() = 0;
9 //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
10 //expected-error@-2 {{'bad2' is not virtual and cannot be declared pure}}
11};
12
13template <typename T>
14class X {
15 virtual T f();
16 //expected-error@-1 {{virtual functions are not supported in OpenCL C++}}
17};
18
19// Test that virtual base classes are allowed.
20struct A {
21 int a;
22 void foo();
23};
24
25struct B : virtual A {
26 int b;
27};
28
29struct C : public virtual A {
30 int c;
31};
32
33struct D : B, C {
34 int d;
35};
36
37kernel void virtual_inheritance() {
38 D d;
39
40 d.foo();
41 d.a = 11;
42 d.b = 22;
43 d.c = 33;
44 d.d = 44;
45}