Fix bug with initializer expression lists for globlal/static array-typed variables.

This commit is contained in:
Matt Pharr
2011-07-28 11:38:56 +01:00
parent 7f662de6e3
commit 158bd6ef9e
3 changed files with 32 additions and 2 deletions

View File

@@ -516,8 +516,12 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
decl->initExpr = decl->initExpr->TypeCheck();
if (decl->initExpr != NULL) {
// We need to make sure the initializer expression is
// the same type as the global
decl->initExpr = decl->initExpr->TypeConv(decl->sym->type, "initializer");
// the same type as the global. (But not if it's an
// 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) {
decl->initExpr = decl->initExpr->Optimize();

View 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;
}

View 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;
}