From beea3ed556775e7b3f49675df46aa2f79dcacd8e Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 26 Nov 2010 12:20:53 +0100 Subject: [PATCH] Check for undefined types. --- src/libs/glsl/glslsemantic.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libs/glsl/glslsemantic.cpp b/src/libs/glsl/glslsemantic.cpp index be643f78d7e..c696ba5d487 100644 --- a/src/libs/glsl/glslsemantic.cpp +++ b/src/libs/glsl/glslsemantic.cpp @@ -514,7 +514,7 @@ bool Semantic::visit(BasicTypeAST *ast) break; default: - qDebug() << "unknown type:" << GLSLParserTable::spell[ast->token]; + _engine->error(ast->lineno, QString("Unknown type `%1'").arg(QLatin1String(GLSLParserTable::spell[ast->token]))); } return false; @@ -522,7 +522,17 @@ bool Semantic::visit(BasicTypeAST *ast) bool Semantic::visit(NamedTypeAST *ast) { - Q_UNUSED(ast); + if (ast->name) { + if (Symbol *s = _scope->lookup(*ast->name)) { + if (Struct *ty = s->asStruct()) { + _expr.type = ty; + _expr.isConstant = false; + return false; + } + } + _engine->error(ast->lineno, QString("Undefined type `%1'").arg(*ast->name)); + } + return false; } @@ -539,6 +549,8 @@ bool Semantic::visit(StructTypeAST *ast) Struct *s = _engine->newStruct(_scope); if (ast->name) s->setName(*ast->name); + if (Scope *e = s->scope()) + e->add(s); Scope *previousScope = switchScope(s); for (List *it = ast->fields; it; it = it->next) { StructTypeAST::Field *f = it->value;