Mesa (master): glsl: Distinguish "type mismatch" error messages for modulus operator.

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Jun 29 23:07:31 UTC 2011


Module: Mesa
Branch: master
Commit: 8eb975394478a5c1ebd2bd8a12b5eb61cef808a7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8eb975394478a5c1ebd2bd8a12b5eb61cef808a7

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Tue Jun 14 22:21:41 2011 -0700

glsl: Distinguish "type mismatch" error messages for modulus operator.

Previously, it would simply say "type error" in three different cases:
- The LHS is not an integer
- The RHS is not an integer
- The LHS and RHS have different base types (int vs. uint)

Now the error messages state the specific problem.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/glsl/ast_to_hir.cpp |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 35cb206..2e54e8c 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -447,9 +447,17 @@ modulus_result_type(const struct glsl_type *type_a,
     *    integer vectors. The operand types must both be signed or both be
     *    unsigned."
     */
-   if (!type_a->is_integer() || !type_b->is_integer()
-       || (type_a->base_type != type_b->base_type)) {
-      _mesa_glsl_error(loc, state, "type mismatch");
+   if (!type_a->is_integer()) {
+      _mesa_glsl_error(loc, state, "LHS of operator %% must be an integer.");
+      return glsl_type::error_type;
+   }
+   if (!type_b->is_integer()) {
+      _mesa_glsl_error(loc, state, "RHS of operator %% must be an integer.");
+      return glsl_type::error_type;
+   }
+   if (type_a->base_type != type_b->base_type) {
+      _mesa_glsl_error(loc, state,
+		       "operands of %% must have the same base type");
       return glsl_type::error_type;
    }
 




More information about the mesa-commit mailing list