From f0eccc398e392f314e9c8472242e3dd7333bd71c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 1 Sep 2024 17:02:42 +0900 Subject: [PATCH] [qfcc] Fix some glsl parsing issues Segfault when debug printing expr values, missing spec_merge for type_qualifier and superfluous ; after for loop init expression. --- tools/qfcc/source/debug.c | 1 + tools/qfcc/source/glsl-parse.y | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/debug.c b/tools/qfcc/source/debug.c index a0747f925..93735aa55 100644 --- a/tools/qfcc/source/debug.c +++ b/tools/qfcc/source/debug.c @@ -115,6 +115,7 @@ set_line_file (int line, const char *file, int flags) .column = 1, .last_line = line, .last_column = 1, + .file = ReuseString (file), }; if (file) { add_source_file (file); diff --git a/tools/qfcc/source/glsl-parse.y b/tools/qfcc/source/glsl-parse.y index 95851cd00..561aa36b8 100644 --- a/tools/qfcc/source/glsl-parse.y +++ b/tools/qfcc/source/glsl-parse.y @@ -203,7 +203,7 @@ int yylex (YYSTYPE *yylval, YYLTYPE *yylloc); %type parameter_declarator parameter_type_specifier %printer { fprintf (yyo, "%s", $$->name); } -%printer { fprintf (yyo, "%s", $$->type == ex_value ? get_value_string ($$->value) : ""); } +%printer { fprintf (yyo, "%s", ($$ && $$->type == ex_value) ? get_value_string ($$->value) : ""); } %printer { fprintf (yyo, "%p", $$); } <*> %printer { fprintf (yyo, "<>"); } <> @@ -744,6 +744,9 @@ precise_qualifer type_qualifier : single_type_qualifier | type_qualifier single_type_qualifier + { + $$ = spec_merge ($1, $2); + } ; single_type_qualifier @@ -1069,7 +1072,7 @@ iteration_statement } | FOR break_label continue_label // '(' for_init_statement for_rest_statement ')' - '(' for_init_statement ';' conditionopt ';' expressionopt ')' + '(' for_init_statement conditionopt ';' expressionopt ')' statement_no_new_scope { if ($for_init_statement) {