• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
4// This test checks that various C++ and OpenCL C keywords are not available
5// in OpenCL.
6
7// Test that exceptions are disabled despite passing -fcxx-exceptions.
8kernel 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;
16  }
17}
18
19// Test that only __-prefixed address space qualifiers are accepted.
20struct test_address_space_qualifiers {
21  global int *g;
22  __global int *uug;
23  int global; // expected-warning{{declaration does not declare anything}}
24
25  local int *l;
26  __local int *uul;
27  int local; // expected-warning{{declaration does not declare anything}}
28
29  private int *p;
30  __private int *uup;
31  int private; // expected-warning{{declaration does not declare anything}}
32
33  constant int *c;
34  __constant int *uuc;
35  int constant; // expected-warning{{declaration does not declare anything}}
36
37  generic int *ge;
38  __generic int *uuge;
39  int generic; // expected-warning{{declaration does not declare anything}}
40};
41
42// Test that 'private' can be parsed as an access qualifier and an address space too.
43class A{
44  private:
45  private int i; //expected-error{{field may not be qualified with an address space}}
46};
47
48private ::A i; //expected-error{{program scope variable must reside in global or constant address space}}
49
50void foo(private int i);
51
52private int bar(); //expected-error{{return value cannot be qualified with address space}}
53