X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fvalidate.h;h=d38849012e26fd4569919eaff31588fb144c3559;hb=59347f76bc985e8c9c769d4a3eee672cba9c920b;hp=fe52ff5aae1878aa0006c2dce8b4c60ca6b4b7af;hpb=ea489c40680f9e8e90eeb163d17c8dddd53981d4;p=libs%2Fgl.git diff --git a/source/glsl/validate.h b/source/glsl/validate.h index fe52ff5a..d3884901 100644 --- a/source/glsl/validate.h +++ b/source/glsl/validate.h @@ -140,6 +140,27 @@ private: virtual void visit(Return &); }; +/** Verifies flow control constructs. Functions returning non-void must have +return statements. Warnings are given about dead code. */ +class FlowControlValidator: private Validator +{ +private: + bool reachable; + +public: + FlowControlValidator(); + + void apply(Stage &s) { stage = &s; s.content.visit(*this); } + +private: + virtual void visit(Block &); + virtual void visit(FunctionDeclaration &); + virtual void visit(Conditional &); + virtual void visit(Iteration &); + virtual void visit(Return &) { reachable = false; } + virtual void visit(Jump &) { reachable = false; } +}; + /** Verifies that stage input and output interfaces are valid. Linked variables must have matching types and locations and there must not be any overlap in locations. */