X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fvalidate.cpp;h=b8710509e8d32fe424062f6c6558976ceab6da35;hb=3f44e477f81983c66947fe8a6d8640a3b2f9e0b3;hp=6e90698c97b500c5dd2edcaebd7e3f8c70e90026;hpb=3a1fe833ea04df75449706f1d773f6e65521a392;p=libs%2Fgl.git diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index 6e90698c..b8710509 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -216,7 +216,7 @@ void ReferenceValidator::visit(VariableReference &var) { if(!var.declaration) error(var, format("Use of undeclared variable '%s'", var.name)); - else if(stage->type!=Stage::VERTEX && var.declaration->interface=="in" && !var.declaration->linked_declaration) + else if(stage->type!=Stage::VERTEX && var.declaration->interface=="in" && var.name.compare(0, 3, "gl_") && !var.declaration->linked_declaration) error(var, format("Use of unlinked input variable '%s'", var.name)); } @@ -239,10 +239,16 @@ void ReferenceValidator::visit(InterfaceBlockReference &iface) void ReferenceValidator::visit(FunctionCall &call) { - if(!call.declaration && !call.constructor) + if((!call.constructor && !call.declaration) || (call.constructor && !call.type)) { - map::iterator i = stage->functions.lower_bound(call.name); - if(i!=stage->functions.end() && i->second->name==call.name) + bool have_declaration = call.constructor; + if(!call.constructor) + { + map::iterator i = stage->functions.lower_bound(call.name); + have_declaration = (i!=stage->functions.end() && i->second->name==call.name); + } + + if(have_declaration) { bool valid_types = true; string signature; @@ -255,7 +261,7 @@ void ReferenceValidator::visit(FunctionCall &call) } if(valid_types) - error(call, format("No matching overload found for call to '%s(%s)'", call.name, signature)); + error(call, format("No matching %s found for '%s(%s)'", (call.constructor ? "constructor" : "overload"), call.name, signature)); } else error(call, format("Call to undeclared function '%s'", call.name)); @@ -338,8 +344,14 @@ void ExpressionValidator::visit(UnaryExpression &unary) void ExpressionValidator::visit(BinaryExpression &binary) { if(!binary.type && binary.left->type && binary.right->type) - error(binary, format("No matching operator '%s' found for '%s' and '%s'", - binary.oper->token, binary.left->type->name, binary.right->type->name)); + { + if(binary.oper->token[0]=='[') + error(binary, format("Can't index element of '%s' with '%s'", + binary.left->type->name, binary.right->type->name)); + else + error(binary, format("No matching operator '%s' found for '%s' and '%s'", + binary.oper->token, binary.left->type->name, binary.right->type->name)); + } TraversingVisitor::visit(binary); }