2016-01-09 20:53:17 +08:00
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
2019-05-22 21:12:20 +08:00
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
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-05-22 21:12:20 +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}}
2017-05-25 15:18:37 +08:00
kernel void test_invalid_reserved_id ( reserve_id_t ID ) { // expected-error {{ 'reserve_id_t ' cannot be used as the type of a kernel parameter}}
}
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 ( ) {
2016-11-18 22:10:54 +08:00
pipe int p ; // expected-error {{type '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 ) {
2016-11-18 22:10:54 +08:00
p+p ; // expected-error{{invalid operands to binary expression ('read_only pipe int' and 'read_only pipe int')}}
p=p ; // expected-error{{invalid operands to binary expression ('read_only pipe int' and 'read_only pipe int')}}
&p ; // expected-error{{invalid argument type 'read_only pipe int' to unary expression}}
*p ; // expected-error{{invalid argument type '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 ;
return ( id1 == id2 ) ; // expected-error {{invalid operands to binary expression ('reserve_id_t' and 'reserve_id_t')}}
}
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