Add _mesa_glsl_warning to emit warnings to the shader log
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 7 Apr 2010 21:47:46 +0000 (14:47 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 7 Apr 2010 23:49:25 +0000 (16:49 -0700)
glsl_parser_extras.cpp
glsl_parser_extras.h

index 1eac1890afe3fa3b34d206826e952cd7eef626ef..de67e849dfa0bfe3ee58d7085bdabc3774a33b9d 100644 (file)
@@ -71,6 +71,25 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
 }
 
 
+void
+_mesa_glsl_warning(const YYLTYPE *locp, const _mesa_glsl_parse_state *state,
+                  const char *fmt, ...)
+{
+   char buf[1024];
+   int len;
+   va_list ap;
+
+   len = snprintf(buf, sizeof(buf), "%u:%u(%u): warning: ",
+                 locp->source, locp->first_line, locp->first_column);
+
+   va_start(ap, fmt);
+   vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
+   va_end(ap);
+
+   printf("%s\n", buf);
+}
+
+
 bool
 _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
                             const char *behavior, YYLTYPE *behavior_locp,
index 15667ebb689f9e167a6b0e94965c7f2c8dd59931..7759eda535fe92c5b6ab49fb946f3e2971f9568d 100644 (file)
@@ -74,6 +74,15 @@ typedef struct YYLTYPE {
 extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
                             const char *fmt, ...);
 
+/**
+ * Emit a warning to the shader log
+ *
+ * \sa _mesa_glsl_error
+ */
+extern void _mesa_glsl_warning(const YYLTYPE *locp,
+                              const _mesa_glsl_parse_state *state,
+                              const char *fmt, ...);
+
 extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
                                  const char *string, size_t len);