59 lines · plain
1// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -fsyntax-only -verify2// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -fsyntax-only -verify -DFUNCPTREXT3 4#ifdef FUNCPTREXT5#pragma OPENCL EXTENSION __cl_clang_function_pointers : enable6//expected-no-diagnostics7#endif8 9// Test that virtual functions and abstract classes are rejected10// unless specific clang extension is used.11class virtual_functions {12 virtual void bad1() {}13#ifndef FUNCPTREXT14 //expected-error@-2 {{virtual functions are not supported in C++ for OpenCL}}15#endif16 17 virtual void bad2() = 0;18#ifndef FUNCPTREXT19 //expected-error@-2 {{virtual functions are not supported in C++ for OpenCL}}20 //expected-error@-3 {{'bad2' is not virtual and cannot be declared pure}}21#endif22};23 24template <typename T>25class X {26 virtual T f();27#ifndef FUNCPTREXT28 //expected-error@-2 {{virtual functions are not supported in C++ for OpenCL}}29#endif30};31 32// Test that virtual base classes are allowed.33struct A {34 int a;35 void foo();36};37 38struct B : virtual A {39 int b;40};41 42struct C : public virtual A {43 int c;44};45 46struct D : B, C {47 int d;48};49 50kernel void virtual_inheritance() {51 D d;52 53 d.foo();54 d.a = 11;55 d.b = 22;56 d.c = 33;57 d.d = 44;58}59