[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Parser / opencl-cxx-keywords.cl
blob365187a9f1c0c38c9d92601f9f2b8a8754002dca
1 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -verify -fsyntax-only
2 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=clc++ -verify -fsyntax-only -fexceptions -fcxx-exceptions
4 // This test checks that various C++ and OpenCL C keywords are not available
5 // in OpenCL.
7 // Test that exceptions are disabled despite passing -fcxx-exceptions.
8 kernel void test_exceptions() {
9 int x;
10 try {
11 // expected-error@-1 {{cannot use 'try' with exceptions disabled}}
12 throw 0;
13 // expected-error@-1 {{cannot use 'throw' with exceptions disabled}}
14 } catch (int i) {
15 x = 41;
19 // Test that only __-prefixed address space qualifiers are accepted.
20 struct test_address_space_qualifiers {
21 global int *g;
22 __global int *uug;
23 int global; // expected-warning{{declaration does not declare anything}}
25 local int *l;
26 __local int *uul;
27 int local; // expected-warning{{declaration does not declare anything}}
29 private int *p;
30 __private int *uup;
31 int private; // expected-warning{{declaration does not declare anything}}
33 constant int *c;
34 __constant int *uuc;
35 int constant; // expected-warning{{declaration does not declare anything}}
37 generic int *ge;
38 __generic int *uuge;
39 int generic; // expected-warning{{declaration does not declare anything}}
42 // Test that 'private' can be parsed as an access qualifier and an address space too.
43 class A{
44 private:
45 private int i; //expected-error{{field may not be qualified with an address space}}
48 private ::A i; //expected-error{{program scope variable must reside in global or constant address space}}
50 void foo(private int i);
52 private int bar(); //expected-error{{return type cannot be qualified with address space}}