xref: /llvm-project/clang/test/SemaOpenCLCXX/references.clcpp (revision d1c8a151df830c6c727f0bb7d33774bd3eb96824)
1//RUN: %clang_cc1 %s -verify -fsyntax-only -triple spir
2//RUN: %clang_cc1 %s -verify -fsyntax-only -DFPTREXT -triple spir
3
4#ifdef FPTREXT
5#pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
6#endif // FPTREXT
7
8// References to functions are not allowed.
9struct myclass {
10//FIXME: Here we provide incorrect diagnostic.
11  void (&mem)(); //expected-error{{reference to function type cannot have '__generic' qualifier}}
12};
13
14void (&glob)();
15#ifndef FPTREXT
16//expected-error@-2{{references to functions are not allowed}}
17#else
18//expected-error@-4{{declaration of reference variable 'glob' requires an initializer}}
19#endif // FPTREXT
20
21using ref2fct_t = void (&)();
22#ifndef FPTREXT
23//expected-error@-2{{references to functions are not allowed}}
24#endif // FPTREXT
25typedef void (&ref2fct_t)();
26#ifndef FPTREXT
27//expected-error@-2{{references to functions are not allowed}}
28#endif // FPTREXT
29
30void test(void (&par)()) {
31#ifndef FPTREXT
32//expected-error@-2{{references to functions are not allowed}}
33#endif // FPTREXT
34  void (&loc)();
35#ifndef FPTREXT
36//expected-error@-2{{references to functions are not allowed}}
37#else
38//expected-error@-4{{declaration of reference variable 'loc' requires an initializer}}
39#endif // FPTREXT
40
41  void (*&ref2fptr)();
42#ifndef FPTREXT
43//expected-error@-2{{pointers to functions are not allowed}}
44#endif // FPTREXT
45//expected-error@-4{{declaration of reference variable 'ref2fptr' requires an initializer}}
46}
47