ast_layout_expression *local_size[3];
};
+class ast_warnings_toggle : public ast_node {
+public:
+ ast_warnings_toggle(bool _enable)
+ : enable(_enable)
+ {
+ /* empty */
+ }
+
+ virtual ir_rvalue *hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state);
+
+private:
+ bool enable;
+};
/*@}*/
extern void
BEGIN PP;
return PRAGMA_OPTIMIZE_OFF;
}
+^{SPC}#{SPC}pragma{SPCP}warning{SPC}\({SPC}on{SPC}\) {
+ BEGIN PP;
+ return PRAGMA_WARNING_ON;
+ }
+^{SPC}#{SPC}pragma{SPCP}warning{SPC}\({SPC}off{SPC}\) {
+ BEGIN PP;
+ return PRAGMA_WARNING_OFF;
+ }
^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) {
BEGIN PP;
return PRAGMA_INVARIANT_ALL;
%token VERSION_TOK EXTENSION LINE COLON EOL INTERFACE OUTPUT
%token PRAGMA_DEBUG_ON PRAGMA_DEBUG_OFF
%token PRAGMA_OPTIMIZE_ON PRAGMA_OPTIMIZE_OFF
+%token PRAGMA_WARNING_ON PRAGMA_WARNING_OFF
%token PRAGMA_INVARIANT_ALL
%token LAYOUT_TOK
%token DOT_TOK
%type <n> unary_operator
%type <expression> function_identifier
%type <node> external_declaration
+%type <node> pragma_statement
%type <declarator_list> init_declarator_list
%type <declarator_list> single_declaration
%type <expression> initializer
;
pragma_statement:
- PRAGMA_DEBUG_ON EOL
- | PRAGMA_DEBUG_OFF EOL
- | PRAGMA_OPTIMIZE_ON EOL
- | PRAGMA_OPTIMIZE_OFF EOL
+ PRAGMA_DEBUG_ON EOL { $$ = NULL; }
+ | PRAGMA_DEBUG_OFF EOL { $$ = NULL; }
+ | PRAGMA_OPTIMIZE_ON EOL { $$ = NULL; }
+ | PRAGMA_OPTIMIZE_OFF EOL { $$ = NULL; }
| PRAGMA_INVARIANT_ALL EOL
{
/* Pragma invariant(all) cannot be used in a fragment shader.
} else {
state->all_invariant = true;
}
+
+ $$ = NULL;
+ }
+ | PRAGMA_WARNING_ON EOL
+ {
+ void *mem_ctx = state->linalloc;
+ $$ = new(mem_ctx) ast_warnings_toggle(true);
+ }
+ | PRAGMA_WARNING_OFF EOL
+ {
+ void *mem_ctx = state->linalloc;
+ $$ = new(mem_ctx) ast_warnings_toggle(false);
}
;
external_declaration:
function_definition { $$ = $1; }
| declaration { $$ = $1; }
- | pragma_statement { $$ = NULL; }
+ | pragma_statement { $$ = $1; }
| layout_defaults { $$ = $1; }
| ';' { $$ = NULL; }
;
gl_shader_stage stage,
void *mem_ctx)
: ctx(_ctx), cs_input_local_size_specified(false), cs_input_local_size(),
- switch_state()
+ switch_state(), warnings_enabled(true)
{
assert(stage < MESA_SHADER_STAGES);
this->stage = stage;
_mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
const char *fmt, ...)
{
- va_list ap;
+ if (state->warnings_enabled) {
+ va_list ap;
- va_start(ap, fmt);
- _mesa_glsl_msg(locp, state, MESA_DEBUG_TYPE_OTHER, fmt, ap);
- va_end(ap);
+ va_start(ap, fmt);
+ _mesa_glsl_msg(locp, state, MESA_DEBUG_TYPE_OTHER, fmt, ap);
+ va_end(ap);
+ }
}