Fix bugs that broke typedefs in function definitions.

Issue #118.
This commit is contained in:
Matt Pharr
2011-12-03 15:15:06 -08:00
parent a1c0b4f95a
commit d492ba08e6
3 changed files with 26 additions and 1 deletions

View File

@@ -495,8 +495,9 @@ declaration_statement
{ {
if ($1->declSpecs->storageClass == SC_TYPEDEF) { if ($1->declSpecs->storageClass == SC_TYPEDEF) {
for (unsigned int i = 0; i < $1->declarators.size(); ++i) { for (unsigned int i = 0; i < $1->declarators.size(); ++i) {
m->AddTypeDef($1->declarators[i]->sym); m->AddTypeDef($1->declarators[i]->GetSymbol());
} }
$$ = NULL;
} }
else { else {
std::vector<VariableDeclaration> vars = $1->GetVariableDeclarations(); std::vector<VariableDeclaration> vars = $1->GetVariableDeclarations();

14
tests/typedef-3.ispc Normal file
View File

@@ -0,0 +1,14 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
typedef float Float[3];
float a = aFOO[programIndex];
Float x;
x[0] = 1;
x[1] = a;
x[2] = 2;
RET[programIndex] = x[b-4];
}
export void result(uniform float RET[]) { RET[programIndex] = 1+programIndex; }

10
tests/typedef-4.ispc Normal file
View File

@@ -0,0 +1,10 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
typedef float Float;
Float a = aFOO[programIndex];
RET[programIndex] = a;
}
export void result(uniform float RET[]) { RET[programIndex] = 1+programIndex; }