1 | // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -pedantic -verify -fsyntax-only |
2 | |
3 | // This test checks that various C/C++/OpenCL C constructs are not available in |
4 | // OpenCL C++, according to OpenCL C++ 1.0 Specification Section 2.9. |
5 | |
6 | // Test that typeid is not available in OpenCL C++. |
7 | namespace std { |
8 | // Provide a dummy std::type_info so that we can use typeid. |
9 | class type_info { |
10 | int a; |
11 | }; |
12 | } |
13 | __constant std::type_info int_ti = typeid(int); |
14 | // expected-error@-1 {{'typeid' is not supported in OpenCL C++}} |
15 | |
16 | // Test that dynamic_cast is not available in OpenCL C++. |
17 | class A { |
18 | public: |
19 | int a; |
20 | }; |
21 | |
22 | class B : public A { |
23 | int b; |
24 | }; |
25 | |
26 | B *test_dynamic_cast(B *p) { |
27 | return dynamic_cast<B *>(p); |
28 | // expected-error@-1 {{'dynamic_cast' is not supported in OpenCL C++}} |
29 | } |
30 | |
31 | // Test storage class qualifiers. |
32 | __constant _Thread_local int a = 1; |
33 | // expected-error@-1 {{OpenCL C++ version 1.0 does not support the '_Thread_local' storage class specifier}} |
34 | __constant __thread int b = 2; |
35 | // expected-error@-1 {{OpenCL C++ version 1.0 does not support the '__thread' storage class specifier}} |
36 | kernel void test_storage_classes() { |
37 | register int x; |
38 | // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'register' storage class specifier}} |
39 | thread_local int y; |
40 | // expected-error@-1 {{OpenCL C++ version 1.0 does not support the 'thread_local' storage class specifier}} |
41 | } |
42 | |