Merge branch 'master' of git://github.com/ispc/ispc

This commit is contained in:
Jean-Luc Duprat
2012-04-18 09:24:35 -07:00
8 changed files with 87 additions and 3 deletions

View File

@@ -3587,6 +3587,9 @@ bool CWriter::visitBuiltinCall(CallInst &I, Intrinsic::ID ID,
// If this is an intrinsic that directly corresponds to a GCC
// builtin, we emit it here.
const char *BuiltinName = "";
#ifdef LLVM_3_0
Function *F = I.getCalledFunction();
#endif // LLVM_3_0
#define GET_GCC_BUILTIN_NAME
#include "llvm/Intrinsics.gen"
#undef GET_GCC_BUILTIN_NAME

View File

@@ -1258,6 +1258,11 @@ UnaryExpr::TypeCheck() {
type->GetString().c_str());
return NULL;
}
if (dynamic_cast<const UndefinedStructType *>(pt->GetBaseType())) {
Error(expr->pos, "Illegal to pre/post increment pointer to "
"undefined struct type \"%s\".", type->GetString().c_str());
return NULL;
}
return this;
}
@@ -2296,6 +2301,16 @@ BinaryExpr::TypeCheck() {
"on \"%s\" type.", type1->GetString().c_str());
return NULL;
}
if (dynamic_cast<const UndefinedStructType *>(pt0->GetBaseType())) {
Error(pos, "Illegal to perform pointer arithmetic "
"on undefined struct type \"%s\".", pt0->GetString().c_str());
return NULL;
}
if (dynamic_cast<const UndefinedStructType *>(pt1->GetBaseType())) {
Error(pos, "Illegal to perform pointer arithmetic "
"on undefined struct type \"%s\".", pt1->GetString().c_str());
return NULL;
}
const Type *t = Type::MoreGeneralType(type0, type1, pos, "-");
if (t == NULL)
@@ -2331,6 +2346,11 @@ BinaryExpr::TypeCheck() {
"on \"%s\" type.", pt0->GetString().c_str());
return NULL;
}
if (dynamic_cast<const UndefinedStructType *>(pt0->GetBaseType())) {
Error(pos, "Illegal to perform pointer arithmetic "
"on undefined struct type \"%s\".", pt0->GetString().c_str());
return NULL;
}
const Type *offsetType = g->target.is32Bit ?
AtomicType::UniformInt32 : AtomicType::UniformInt64;
@@ -7336,6 +7356,14 @@ SizeOfExpr::Print() const {
Expr *
SizeOfExpr::TypeCheck() {
// Can't compute the size of a struct without a definition
if (type != NULL &&
dynamic_cast<const UndefinedStructType *>(type) != NULL) {
Error(pos, "Can't compute the size of declared but not defined "
"struct type \"%s\".", type->GetString().c_str());
return NULL;
}
return this;
}
@@ -8105,9 +8133,20 @@ NewExpr::GetType() const {
Expr *
NewExpr::TypeCheck() {
// Here we only need to make sure that if we have an expression giving
// a number of elements to allocate that it can be converted to an
// integer of the appropriate variability.
// It's illegal to call new with an undefined struct type
if (allocType == NULL) {
Assert(m->errorCount > 0);
return NULL;
}
if (dynamic_cast<const UndefinedStructType *>(allocType) != NULL) {
Error(pos, "Can't dynamically allocate storage for declared "
"but not defined type \"%s\".", allocType->GetString().c_str());
return NULL;
}
// Otherwise we only need to make sure that if we have an expression
// giving a number of elements to allocate that it can be converted to
// an integer of the appropriate variability.
if (countExpr == NULL)
return this;

View File

@@ -0,0 +1,7 @@
// Can't dynamically allocate storage for declared but not defined type
struct Foo;
Foo * uniform bar() {
return uniform new Foo;
}

View File

@@ -0,0 +1,7 @@
// Illegal to perform pointer arithmetic on undefined struct type
struct Foo;
Foo * uniform bar(Foo * uniform f) {
return f + 1;
}

View File

@@ -0,0 +1,7 @@
// Illegal to perform pointer arithmetic on undefined struct type
struct Foo;
Foo * uniform bar(Foo * uniform f) {
return 1 + f;
}

View File

@@ -0,0 +1,7 @@
// Illegal to perform pointer arithmetic on undefined struct type
struct Foo;
Foo * uniform bar(Foo * uniform f) {
return f-1;
}

View File

@@ -0,0 +1,7 @@
// Illegal to pre/post increment pointer to undefined struct type
struct Foo;
Foo * uniform bar(Foo * uniform f) {
return ++f;
}

View File

@@ -0,0 +1,7 @@
// Can't compute the size of declared but not defined struct type
struct Foo;
uniform int bar() {
return sizeof(Foo);
}