2016-01-09 20:53:17 +08:00
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
2019-07-25 19:04:29 +08:00
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
2016-01-09 20:53:17 +08:00
2016-11-29 18:21:40 +08:00
global pipe int gp ; // expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
global reserve_id_t rid ; // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
2019-11-27 19:03:11 +08:00
extern pipe write_only int get_pipe ( ) ; // expected-error-re{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}} expected-error{{'write_only' attribute only applies to parameters and typedefs}}
2017-05-25 15:18:37 +08:00
2019-12-27 21:38:48 +08:00
kernel void test_invalid_reserved_id ( reserve_id_t ID ) { // expected-error {{ '__private reserve_id_t ' cannot be used as the type of a kernel parameter}}
2017-05-25 15:18:37 +08:00
}
2016-07-11 21:46:02 +08:00
void test1 ( pipe int *p ) {// expected-error {{pipes packet types cannot be of reference type}}
2016-01-09 20:53:17 +08:00
}
2016-07-11 21:46:02 +08:00
void test2 ( pipe p ) {// expected-error {{missing actual type specifier for pipe}}
2016-01-09 20:53:17 +08:00
}
2016-07-11 21:46:02 +08:00
void test3 ( int pipe p ) {// expected-error {{cannot combine with previous 'int ' declaration specifier}}
2016-01-09 20:53:17 +08:00
}
2016-02-25 11:34:20 +08:00
void test4 ( ) {
2019-12-27 21:38:48 +08:00
pipe int p ; // expected-error {{type '__private read_only pipe int' can only be used as a function parameter}}
2016-07-11 21:46:02 +08:00
//TODO: fix parsing of this pipe int ( *p ) ;
2016-02-25 11:34:20 +08:00
}
2016-07-11 21:46:02 +08:00
void test5 ( pipe int p ) {
2019-12-27 21:38:48 +08:00
p+p ; // expected-error{{invalid operands to binary expression ('__private read_only pipe int' and '__private read_only pipe int')}}
p=p ; // expected-error{{invalid operands to binary expression ('__private read_only pipe int' and '__private read_only pipe int')}}
&p ; // expected-error{{invalid argument type '__private read_only pipe int' to unary expression}}
*p ; // expected-error{{invalid argument type '__private read_only pipe int' to unary expression}}
2016-07-11 21:46:02 +08:00
}
typedef pipe int pipe_int_t ;
2016-11-18 22:10:54 +08:00
pipe_int_t test6 ( ) {} // expected-error{{declaring function return value of type 'pipe_int_t ' ( aka 'read_only pipe int ' ) is not allowed}}
2016-11-29 18:21:40 +08:00
bool test_id_comprision ( void ) {
reserve_id_t id1, id2 ;
2019-12-27 21:38:48 +08:00
return ( id1 == id2 ) ; // expected-error {{invalid operands to binary expression ('__private reserve_id_t' and '__private reserve_id_t')}}
2016-11-29 18:21:40 +08:00
}
2016-12-01 19:30:49 +08:00
// Tests ASTContext::mergeTypes rejects this.
2019-05-22 21:12:20 +08:00
# ifndef __OPENCL_CPP_VERSION__
2016-12-01 19:30:49 +08:00
int f ( pipe int x, int y ) ; // expected-note {{previous declaration is here}}
int f ( x, y ) // expected-error {{conflicting types for 'f}}
pipe short x ;
int y ;
{
return y ;
}
2019-05-22 21:12:20 +08:00
# endif