Fix bug with initializer expression lists for globlal/static array-typed variables.
This commit is contained in:
@@ -516,8 +516,12 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
|
|||||||
decl->initExpr = decl->initExpr->TypeCheck();
|
decl->initExpr = decl->initExpr->TypeCheck();
|
||||||
if (decl->initExpr != NULL) {
|
if (decl->initExpr != NULL) {
|
||||||
// We need to make sure the initializer expression is
|
// We need to make sure the initializer expression is
|
||||||
// the same type as the global
|
// the same type as the global. (But not if it's an
|
||||||
decl->initExpr = decl->initExpr->TypeConv(decl->sym->type, "initializer");
|
// ExprList; they don't have types per se / can't type
|
||||||
|
// convert themselves anyway.)
|
||||||
|
if (dynamic_cast<ExprList *>(decl->initExpr) == NULL)
|
||||||
|
decl->initExpr =
|
||||||
|
decl->initExpr->TypeConv(decl->sym->type, "initializer");
|
||||||
|
|
||||||
if (decl->initExpr != NULL) {
|
if (decl->initExpr != NULL) {
|
||||||
decl->initExpr = decl->initExpr->Optimize();
|
decl->initExpr = decl->initExpr->Optimize();
|
||||||
|
|||||||
13
tests/static-array-init-1.ispc
Normal file
13
tests/static-array-init-1.ispc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
static uniform float foo[4] = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
export uniform int width() { return programCount; }
|
||||||
|
|
||||||
|
|
||||||
|
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||||
|
RET[programIndex] = foo[b-3];
|
||||||
|
}
|
||||||
|
|
||||||
|
export void result(uniform float RET[]) {
|
||||||
|
RET[programIndex] = 3;
|
||||||
|
}
|
||||||
13
tests/static-array-init.ispc
Normal file
13
tests/static-array-init.ispc
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
static uniform int foo[4] = { 1, 2, 3, 4 };
|
||||||
|
|
||||||
|
export uniform int width() { return programCount; }
|
||||||
|
|
||||||
|
|
||||||
|
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||||
|
RET[programIndex] = foo[b-3];
|
||||||
|
}
|
||||||
|
|
||||||
|
export void result(uniform float RET[]) {
|
||||||
|
RET[programIndex] = 3;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user