14
parse.yy
14
parse.yy
@@ -909,11 +909,21 @@ struct_or_union_specifier
|
||||
}
|
||||
| struct_or_union '{' '}'
|
||||
{
|
||||
Error(@1, "Empty struct definitions not allowed.");
|
||||
llvm::SmallVector<const Type *, 8> elementTypes;
|
||||
llvm::SmallVector<std::string, 8> elementNames;
|
||||
llvm::SmallVector<SourcePos, 8> elementPositions;
|
||||
$$ = new StructType("", elementTypes, elementNames, elementPositions,
|
||||
false, Variability::Unbound, @1);
|
||||
}
|
||||
| struct_or_union struct_or_union_name '{' '}'
|
||||
{
|
||||
Error(@1, "Empty struct definitions not allowed.");
|
||||
llvm::SmallVector<const Type *, 8> elementTypes;
|
||||
llvm::SmallVector<std::string, 8> elementNames;
|
||||
llvm::SmallVector<SourcePos, 8> elementPositions;
|
||||
StructType *st = new StructType($2, elementTypes, elementNames, elementPositions,
|
||||
false, Variability::Unbound, @1);
|
||||
m->symbolTable->AddType($2, st, @2);
|
||||
$$ = st;
|
||||
}
|
||||
| struct_or_union struct_or_union_name
|
||||
{
|
||||
|
||||
13
tests/empty-struct.ispc
Normal file
13
tests/empty-struct.ispc
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
struct Foo { };
|
||||
|
||||
export void f_f(uniform float RET[], uniform float aFOO[]) {
|
||||
uniform Foo f;
|
||||
RET[programIndex] = sizeof(f);
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = 1;
|
||||
}
|
||||
30
type.cpp
30
type.cpp
@@ -1828,19 +1828,25 @@ StructType::StructType(const std::string &n, const llvm::SmallVector<const Type
|
||||
|
||||
// Actually make the LLVM struct
|
||||
std::vector<llvm::Type *> elementTypes;
|
||||
for (int i = 0; i < GetElementCount(); ++i) {
|
||||
const Type *type = GetElementType(i);
|
||||
if (type == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return;
|
||||
int nElements = GetElementCount();
|
||||
if (nElements == 0) {
|
||||
elementTypes.push_back(LLVMTypes::Int8Type);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < nElements; ++i) {
|
||||
const Type *type = GetElementType(i);
|
||||
if (type == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return;
|
||||
}
|
||||
else if (CastType<FunctionType>(type) != NULL) {
|
||||
Error(elementPositions[i], "Method declarations are not "
|
||||
"supported.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
elementTypes.push_back(type->LLVMType(g->ctx));
|
||||
}
|
||||
else if (CastType<FunctionType>(type) != NULL) {
|
||||
Error(elementPositions[i], "Method declarations are not "
|
||||
"supported.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
elementTypes.push_back(type->LLVMType(g->ctx));
|
||||
}
|
||||
|
||||
if (lStructTypeMap.find(mname) == lStructTypeMap.end()) {
|
||||
|
||||
Reference in New Issue
Block a user