Mesa (7.10): glcpp: Raise error when modulus is zero
Ian Romanick
idr at kemper.freedesktop.org
Tue Mar 1 00:01:36 UTC 2011
Module: Mesa
Branch: 7.10
Commit: 0ca5a1593dc090ac54151ac6cbdeb8a9cb749177
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ca5a1593dc090ac54151ac6cbdeb8a9cb749177
Author: Chad Versace <chad.versace at intel.com>
Date: Wed Feb 2 10:15:19 2011 -0800
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.
(cherry picked from commit fd1252ab67abb1ea351195e192429f292667a8a2)
---
src/glsl/glcpp/glcpp-parse.y | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 5e218ad..7c51299 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) {
More information about the mesa-commit
mailing list