mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-07 08:34:59 +00:00
[OpenCL] Variables in the constant address space must be initialized.
llvm-svn: 198417
This commit is contained in:
parent
5dff61d322
commit
96b94e610b
@ -6714,6 +6714,8 @@ def err_opencl_global_invalid_addr_space : Error<
|
||||
def err_opencl_no_main : Error<"%select{function|kernel}0 cannot be called 'main'">;
|
||||
def err_opencl_kernel_attr :
|
||||
Error<"attribute %0 can only be applied to a kernel function">;
|
||||
def err_opencl_constant_no_init : Error<
|
||||
"variable in constant address space must be initialized">;
|
||||
} // end of sema category
|
||||
|
||||
let CategoryName = "OpenMP Issue" in {
|
||||
|
@ -8589,6 +8589,16 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
|
||||
return;
|
||||
}
|
||||
|
||||
// OpenCL v1.1 s6.5.3: variables declared in the constant address space must
|
||||
// be initialized.
|
||||
if (!Var->isInvalidDecl() &&
|
||||
Var->getType().getAddressSpace() == LangAS::opencl_constant &&
|
||||
!Var->getInit()) {
|
||||
Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
|
||||
Var->setInvalidDecl();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Var->isThisDeclarationADefinition()) {
|
||||
case VarDecl::Definition:
|
||||
if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
|
||||
|
@ -3,17 +3,19 @@
|
||||
|
||||
// Test the forced language options for OpenCL are set correctly.
|
||||
|
||||
__constant int v0[(sizeof(int) == 4) -1];
|
||||
__constant int v1[(__alignof(int) == 4) -1];
|
||||
__constant int v2[(sizeof(long) == 8) -1];
|
||||
__constant int v3[(__alignof(long) == 8) -1];
|
||||
__constant int v4[(sizeof(long long) == 16) -1];
|
||||
__constant int v5[(__alignof(long long) == 16) -1];
|
||||
__constant int v6[(sizeof(float) == 4) -1];
|
||||
__constant int v7[(__alignof(float) == 4) -1];
|
||||
kernel void test() {
|
||||
int v0[(sizeof(int) == 4) - 1];
|
||||
int v1[(__alignof(int)== 4) - 1];
|
||||
int v2[(sizeof(long) == 8) - 1];
|
||||
int v3[(__alignof(long)== 8) - 1];
|
||||
int v4[(sizeof(long long) == 16) - 1];
|
||||
int v5[(__alignof(long long)== 16) - 1];
|
||||
int v6[(sizeof(float) == 4) - 1];
|
||||
int v7[(__alignof(float)== 4) - 1];
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
__constant int v8[(sizeof(double)==8) -1];
|
||||
__constant int v9[(__alignof(double)==8) -1];
|
||||
int v8[(sizeof(double) == 8) - 1];
|
||||
int v9[(__alignof(double)== 8) - 1];
|
||||
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
||||
__constant int v10[(sizeof(half) == 2) -1];
|
||||
__constant int v11[(__alignof(half) == 2) -1];
|
||||
int v10[(sizeof(half) == 2) - 1];
|
||||
int v11[(__alignof(half) == 2) - 1];
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ event_t glb_evt; // expected-error {{the event_t type cannot be used to declare
|
||||
|
||||
constant struct evt_s {
|
||||
event_t evt; // expected-error {{the event_t type cannot be used to declare a structure or union field}}
|
||||
} evt_str;
|
||||
} evt_str = {0};
|
||||
|
||||
void foo(event_t evt); // expected-note {{passing argument to parameter 'evt' here}}
|
||||
|
||||
|
@ -20,11 +20,11 @@ __attribute__((work_group_size_hint(8,16,32))) void kernel9(){} // expected-erro
|
||||
|
||||
__attribute__((vec_type_hint(char))) void kernel10(){} // expected-error {{attribute 'vec_type_hint' can only be applied to a kernel}}
|
||||
|
||||
constant int foo1 __attribute__((reqd_work_group_size(8,16,32))); // expected-error {{'reqd_work_group_size' attribute only applies to functions}}
|
||||
constant int foo1 __attribute__((reqd_work_group_size(8,16,32))) = 0; // expected-error {{'reqd_work_group_size' attribute only applies to functions}}
|
||||
|
||||
constant int foo2 __attribute__((work_group_size_hint(8,16,32))); // expected-error {{'work_group_size_hint' attribute only applies to functions}}
|
||||
constant int foo2 __attribute__((work_group_size_hint(8,16,32))) = 0; // expected-error {{'work_group_size_hint' attribute only applies to functions}}
|
||||
|
||||
constant int foo3 __attribute__((vec_type_hint(char))); // expected-error {{'vec_type_hint' attribute only applies to functions}}
|
||||
constant int foo3 __attribute__((vec_type_hint(char))) = 0; // expected-error {{'vec_type_hint' attribute only applies to functions}}
|
||||
|
||||
void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
|
||||
int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
|
||||
|
Loading…
Reference in New Issue
Block a user