25
expr.cpp
25
expr.cpp
@@ -4277,11 +4277,19 @@ IndexExpr::TypeCheck() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CastType<SequentialType>(baseExprType->GetReferenceTarget()) &&
|
if (!CastType<SequentialType>(baseExprType->GetReferenceTarget())) {
|
||||||
!CastType<PointerType>(baseExprType)) {
|
if (const PointerType *pt = CastType<PointerType>(baseExprType)) {
|
||||||
Error(pos, "Trying to index into non-array, vector, or pointer "
|
if (Type::Equal(AtomicType::Void, pt->GetBaseType())) {
|
||||||
|
Error(pos, "Illegal to dereference void pointer type \"%s\".",
|
||||||
|
baseExprType->GetString().c_str());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Error(pos, "Trying to index into non-array, vector, or pointer "
|
||||||
"type \"%s\".", baseExprType->GetString().c_str());
|
"type \"%s\".", baseExprType->GetString().c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isUniform = (index->GetType()->IsUniformType() &&
|
bool isUniform = (index->GetType()->IsUniformType() &&
|
||||||
@@ -7172,7 +7180,14 @@ PtrDerefExpr::TypeCheck() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CastType<PointerType>(type) == NULL) {
|
if (const PointerType *pt = CastType<PointerType>(type)) {
|
||||||
|
if (Type::Equal(AtomicType::Void, pt->GetBaseType())) {
|
||||||
|
Error(pos, "Illegal to dereference void pointer type \"%s\".",
|
||||||
|
type->GetString().c_str());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
Error(pos, "Illegal to dereference non-pointer type \"%s\".",
|
Error(pos, "Illegal to dereference non-pointer type \"%s\".",
|
||||||
type->GetString().c_str());
|
type->GetString().c_str());
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
5
tests_errors/void-ptr-deref-1.ispc
Normal file
5
tests_errors/void-ptr-deref-1.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// Illegal to dereference void pointer type
|
||||||
|
|
||||||
|
int foo(void * uniform ptr) {
|
||||||
|
print("%", ptr[0]);
|
||||||
|
}
|
||||||
5
tests_errors/void-ptr-deref.ispc
Normal file
5
tests_errors/void-ptr-deref.ispc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
// Illegal to dereference void pointer type
|
||||||
|
|
||||||
|
int foo(void * uniform ptr) {
|
||||||
|
print("%", *ptr);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user