Zebediah Figura : vkd3d-shader/preproc: Allow capital U and L after integer constants as well.
Alexandre Julliard
julliard at winehq.org
Wed Feb 2 16:35:20 CST 2022
Module: vkd3d
Branch: master
Commit: 13a1ba4263287b04727c659b1c735b2b44a6de9f
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=13a1ba4263287b04727c659b1c735b2b44a6de9f
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Wed Feb 2 13:46:16 2022 +0100
vkd3d-shader/preproc: Allow capital U and L after integer constants as well.
Technically we shouldn't allow "uu" or "ll" either, but we also don't really
handle preprocessor parsing errors the way we should.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/preproc.l | 7 ++++---
tests/preproc-if-expr.shader_test | 33 +++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index bf4d669..5454233 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -57,6 +57,7 @@ static void update_location(struct preproc_ctx *ctx);
NEWLINE \r?\n
WS [ \t]
IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
+INT_SUFFIX [uUlL]{0,2}
%%
@@ -92,9 +93,9 @@ IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
<INITIAL>[0-9]+\.([eE][+-]?[0-9]+)?[hHfF]? {return T_TEXT;}
<INITIAL>[0-9]+([eE][+-]?[0-9]+)?[hHfF] {return T_TEXT;}
<INITIAL>[0-9]+[eE][+-]?[0-9]+ {return T_TEXT;}
-<INITIAL,LINE>0[xX][0-9a-fA-f]+[ul]{0,2} {return T_INTEGER;}
-<INITIAL,LINE>0[0-7]*[ul]{0,2} {return T_INTEGER;}
-<INITIAL,LINE>[1-9][0-9]*[ul]{0,2} {return T_INTEGER;}
+<INITIAL,LINE>0[xX][0-9a-fA-f]+{INT_SUFFIX} {return T_INTEGER;}
+<INITIAL,LINE>0[0-7]*{INT_SUFFIX} {return T_INTEGER;}
+<INITIAL,LINE>[1-9][0-9]*{INT_SUFFIX} {return T_INTEGER;}
<INITIAL>## {return T_CONCAT;}
diff --git a/tests/preproc-if-expr.shader_test b/tests/preproc-if-expr.shader_test
index 61c5a39..823b9b0 100644
--- a/tests/preproc-if-expr.shader_test
+++ b/tests/preproc-if-expr.shader_test
@@ -99,6 +99,39 @@ pass
pass
#endif
+[preproc]
+#if 2u == 2
+pass
+#else
+fail
+#endif
+
+[preproc]
+#if 2l == 2
+pass
+#else
+fail
+#endif
+
+[preproc]
+#if 2Ul == 2
+pass
+#else
+fail
+#endif
+
+[preproc]
+#if 2uL == 2
+pass
+#else
+fail
+#endif
+
+[preproc]
+#if 012lu == 10
+pass
+#endif
+
[preproc]
/* All math is done using unsigned 32-bit integers. */
#if 8 / -3 == 2
More information about the wine-cvs
mailing list