diff options
author | Ian Romanick <[email protected]> | 2018-11-01 13:50:14 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2018-11-08 11:00:00 -0800 |
commit | c5a4c264508d3b36663779b89ec0dbaf7653df96 (patch) | |
tree | 0e27e48dc1617316c2312a271963ff36bc0befe4 /src/compiler/glsl/glsl_parser.yy | |
parent | 011abfc963a734953a0edd9c7a4fa01570627050 (diff) |
glsl: Add pragma to disable all warnings
Use #pragma warning(off) and #pragma warning(on) to disable or enable
all warnings. This is a big hammer. If we ever need a smaller hammer,
we can enhance this functionality.
There is one lame thing about this. Because we parse everything, create
an AST, then convert the AST to GLSL IR, we have to treat the #pragma
like a statment. This means that you can't do something like
' void
' #pragma warning(off)
' __foo
' #pragma warning(on)
' (float param0);
Fixing that would, as far as I can tell, require a huge amount of work.
I did try just handling the #pragma during parsing (like we do for
state for the whole shader.
v2: Fix the #pragma lines in the commit message that git-commit ate.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glsl_parser.yy')
-rw-r--r-- | src/compiler/glsl/glsl_parser.yy | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy index fd1592beca0..ddb54f4a4d6 100644 --- a/src/compiler/glsl/glsl_parser.yy +++ b/src/compiler/glsl/glsl_parser.yy @@ -164,6 +164,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2, %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 @@ -246,6 +247,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2, %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 @@ -328,10 +330,10 @@ version_statement: ; 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. @@ -353,6 +355,18 @@ pragma_statement: } 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); } ; @@ -2723,7 +2737,7 @@ jump_statement: external_declaration: function_definition { $$ = $1; } | declaration { $$ = $1; } - | pragma_statement { $$ = NULL; } + | pragma_statement { $$ = $1; } | layout_defaults { $$ = $1; } | ';' { $$ = NULL; } ; |