glsl: Annotate _mesa_glsl_error() with PRINTFLIKE
authorCaio Oliveira <caio.oliveira@intel.com>
Wed, 13 Sep 2023 07:41:43 +0000 (00:41 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 15 Sep 2023 00:45:05 +0000 (00:45 +0000)
And fix all the errors it found.

Note that for the unsized array error, we will print the
toplevel type -- so that the fact that an inner array is
unsized can be seen.

Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25200>

src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/glsl_parser.yy
src/compiler/glsl/glsl_parser_extras.h

index b6d2601..1d70f07 100644 (file)
@@ -1537,8 +1537,8 @@ ast_expression::do_hir(exec_list *instructions,
        */
 
       if (op[0]->type == glsl_type::void_type || op[1]->type == glsl_type::void_type) {
-         _mesa_glsl_error(& loc, state, "`%s':  wrong operand types: "
-                         "no operation `%1$s' exists that takes a left-hand "
+         _mesa_glsl_error(& loc, state, "wrong operand types: "
+                         "no operation `%s' exists that takes a left-hand "
                          "operand of type 'void' or a right operand of type "
                          "'void'", (this->oper == ast_equal) ? "==" : "!=");
          error_emitted = true;
@@ -3676,14 +3676,15 @@ static inline void
 validate_array_dimensions(const glsl_type *t,
                           struct _mesa_glsl_parse_state *state,
                           YYLTYPE *loc) {
+   const glsl_type *top = t;
    if (t->is_array()) {
       t = t->fields.array;
       while (t->is_array()) {
          if (t->is_unsized_array()) {
             _mesa_glsl_error(loc, state,
                              "only the outermost array dimension can "
-                             "be unsized",
-                             t->name);
+                             "be unsized, but got %s",
+                             top->name);
             break;
          }
          t = t->fields.array;
index 1371ecd..e1dc7a9 100644 (file)
@@ -1800,7 +1800,7 @@ layout_qualifier_id:
          if (!state->has_geometry_shader()) {
             _mesa_glsl_error(& @3, state,
                              "#version 150 max_vertices qualifier "
-                             "specified", $3);
+                             "specified");
          }
       }
 
index 3d956a9..fcda943 100644 (file)
@@ -77,7 +77,7 @@ typedef struct YYLTYPE {
 # define YYLTYPE_IS_TRIVIAL 1
 
 extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
-                             const char *fmt, ...);
+                             const char *fmt, ...) PRINTFLIKE(3, 4);
 
 
 struct _mesa_glsl_parse_state {