From 56b8b214107a0320c7277cd832480998057f8413 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 7 Apr 2010 14:47:46 -0700 Subject: [PATCH] Add _mesa_glsl_warning to emit warnings to the shader log --- glsl_parser_extras.cpp | 19 +++++++++++++++++++ glsl_parser_extras.h | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 1eac1890afe..de67e849dfa 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -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, diff --git a/glsl_parser_extras.h b/glsl_parser_extras.h index 15667ebb689..7759eda535f 100644 --- a/glsl_parser_extras.h +++ b/glsl_parser_extras.h @@ -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); -- 2.30.2