[PATCH vkd3d 3/5] vkd3d-shader: Implement #ifndef.

Zebediah Figura zfigura at codeweavers.com
Tue Jan 5 10:18:55 CST 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 libs/vkd3d-shader/preproc.l | 4 ++++
 libs/vkd3d-shader/preproc.y | 6 ++++++
 tests/hlsl_d3d12.c          | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libs/vkd3d-shader/preproc.l b/libs/vkd3d-shader/preproc.l
index b79e5f97..f0e0b63d 100644
--- a/libs/vkd3d-shader/preproc.l
+++ b/libs/vkd3d-shader/preproc.l
@@ -112,6 +112,8 @@ IDENTIFIER      [A-Za-z_][A-Za-z0-9_]*
             return T_IF;
         if (!strcmp(p, "ifdef"))
             return T_IFDEF;
+        if (!strcmp(p, "ifndef"))
+            return T_IFNDEF;
 
         preproc_warning(ctx, yyget_lloc(yyscanner), VKD3D_SHADER_WARNING_PP_UNKNOWN_DIRECTIVE,
                 "Ignoring unknown directive \"%s\".", yytext);
@@ -202,6 +204,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
                 case T_ENDIF:
                 case T_IF:
                 case T_IFDEF:
+                case T_IFNDEF:
                     ctx->current_directive = token;
                     break;
 
@@ -222,6 +225,7 @@ int yylex(YYSTYPE *lval, YYLTYPE *lloc, yyscan_t scanner)
             case T_ENDIF:
             case T_IF:
             case T_IFDEF:
+            case T_IFNDEF:
                 break;
 
             default:
diff --git a/libs/vkd3d-shader/preproc.y b/libs/vkd3d-shader/preproc.y
index c66c0b9d..b1d0c0f0 100644
--- a/libs/vkd3d-shader/preproc.y
+++ b/libs/vkd3d-shader/preproc.y
@@ -185,6 +185,7 @@ static uint32_t preproc_parse_integer(const char *s)
 %token T_ENDIF "#endif"
 %token T_IF "#if"
 %token T_IFDEF "#ifdef"
+%token T_IFNDEF "#ifndef"
 
 %type <integer> expr
 %type <string> body_token
@@ -226,6 +227,11 @@ directive
             preproc_push_if(ctx, !!preproc_find_macro(ctx, $2));
             vkd3d_free($2);
         }
+    | T_IFNDEF T_IDENTIFIER T_NEWLINE
+        {
+            preproc_push_if(ctx, !preproc_find_macro(ctx, $2));
+            vkd3d_free($2);
+        }
     | T_ELIF expr T_NEWLINE
         {
             if (ctx->if_count)
diff --git a/tests/hlsl_d3d12.c b/tests/hlsl_d3d12.c
index 38c1ab2c..8b8c3023 100644
--- a/tests/hlsl_d3d12.c
+++ b/tests/hlsl_d3d12.c
@@ -349,7 +349,7 @@ static void test_preprocess(void)
 
     for (i = 0; i < ARRAY_SIZE(tests); ++i)
     {
-        if (i == 6)
+        if (i == 6 || i == 10 || i == 11)
             continue;
         vkd3d_test_set_context("Source \"%s\"", tests[i].source);
         todo_if (i <= 4 || (i >= 9 && i <= 14))
-- 
2.30.0




More information about the wine-devel mailing list