On 1/19/21 4:24 AM, Matteo Bruni wrote:
On Mon, Jan 18, 2021 at 10:34 PM Zebediah Figura zfigura@codeweavers.com wrote:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
libs/vkd3d-shader/preproc.l | 2 +- libs/vkd3d-shader/preproc.y | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l index 011f8dbb..a522b7c8 100644 --- a/libs/vkd3d-shader/preproc.l +++ b/libs/vkd3d-shader/preproc.l @@ -157,7 +157,7 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]* }
<INITIAL>{WS}+ {} -<INITIAL>[-()[]{},+!] {return yytext[0];} +<INITIAL>[-()[]{},+!*/] {return yytext[0];} <INITIAL>. {return T_TEXT;}
%% diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y index 51df5d40..1060e9d7 100644 --- a/libs/vkd3d-shader/preproc.y +++ b/libs/vkd3d-shader/preproc.y @@ -335,6 +335,7 @@ static void free_parse_arg_names(struct parse_arg_names *args)
%type <integer> primary_expr %type <integer> unary_expr +%type <integer> mul_expr %type <string> body_token %type <const_string> body_token_const %type <string_buffer> body_text @@ -439,6 +440,14 @@ body_token_const { $$ = "!"; }
- | '*'
{
$$ = "*";
}
- | '/'
{
$$ = "/";
| T_CONCAT { $$ = "##";}
@@ -480,7 +489,7 @@ directive } vkd3d_free($2); }
- | T_IF unary_expr T_NEWLINE
- | T_IF mul_expr T_NEWLINE { if (!preproc_push_if(ctx, !!$2)) YYABORT;
@@ -495,7 +504,7 @@ directive preproc_push_if(ctx, !preproc_find_macro(ctx, $2)); vkd3d_free($2); }
- | T_ELIF unary_expr T_NEWLINE
- | T_ELIF mul_expr T_NEWLINE { const struct preproc_file *file = preproc_get_top_file(ctx);
@@ -631,3 +640,14 @@ unary_expr { $$ = !$2; }
+mul_expr
- : unary_expr
- | mul_expr '*' unary_expr
{
$$ = $1 * $3;
}
- | mul_expr '/' unary_expr
{
$$ = $1 / $3;
}
I don't know that we care but notice that e.g. "#if 1 / 0" causes a floating point exception.
Yes, that probably shouldn't be allowed to crash the preprocessor, thanks for catching that.