summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Versace <[email protected]>2011-02-02 10:15:19 -0800
committerChad Versace <[email protected]>2011-02-02 10:19:51 -0800
commitfd1252ab67abb1ea351195e192429f292667a8a2 (patch)
treed4fa11a44db00a68cb198f5446cbdbf797a9026e
parente7c1f058d18f62aa4871aec623f994d7b68cb8c1 (diff)
glcpp: Raise error when modulus is zero
For example, this now raises an error: #define XXX 1 / 0 Fixes bug: https://bugs.freedesktop.org//show_bug.cgi?id=33507 Fixes Piglit test: spec/glsl-1.10/preprocessor/modulus-by-zero.vert NOTE: This is a candidate for the 7.9 and 7.10 branches.
-rw-r--r--src/glsl/glcpp/glcpp-parse.y7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index aa5a0c4f209..1f6e67fa062 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -388,7 +388,12 @@ expression:
$$ = $1 + $3;
}
| expression '%' expression {
- $$ = $1 % $3;
+ if ($3 == 0) {
+ yyerror (& @1, parser,
+ "zero modulus in preprocessor directive");
+ } else {
+ $$ = $1 % $3;
+ }
}
| expression '/' expression {
if ($3 == 0) {