[gtk+/wip/otte/shader: 222/226] gskslpreprocessor: Error if #endif is missing



commit 5bb7c2ecc3f1fa238ff8a8486bec30809eda18b2
Author: Benjamin Otte <otte redhat com>
Date:   Wed Oct 25 21:21:38 2017 +0200

    gskslpreprocessor: Error if #endif is missing

 gsk/gskslpreprocessor.c                            |    9 +++++++++
 .../gsksl/errors/missing-endif-after-if-0.glsl     |    6 ++++++
 .../gsksl/errors/missing-endif-after-if-1.glsl     |    6 ++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskslpreprocessor.c b/gsk/gskslpreprocessor.c
index 6f748ff..6a1c6fe 100644
--- a/gsk/gskslpreprocessor.c
+++ b/gsk/gskslpreprocessor.c
@@ -295,6 +295,15 @@ gsk_sl_preprocessor_append_token (GskSlPreprocessor *preproc,
       return;
     }
 
+  if (gsk_sl_token_is (&pp->token, GSK_SL_TOKEN_EOF))
+    {
+      while (gsk_sl_preprocessor_has_conditional (preproc))
+        {
+          gsk_sl_preprocessor_pop_conditional (preproc);
+          gsk_sl_preprocessor_error_full (preproc, PREPROCESSOR, &pp->location, "Missing #endif.");
+        }
+    }
+
   if (gsk_sl_preprocessor_in_ignored_conditional (preproc))
     {
       gsk_sl_preprocessor_clear_token (pp);
diff --git a/testsuite/gsksl/errors/missing-endif-after-if-0.glsl 
b/testsuite/gsksl/errors/missing-endif-after-if-0.glsl
new file mode 100644
index 0000000..91f3636
--- /dev/null
+++ b/testsuite/gsksl/errors/missing-endif-after-if-0.glsl
@@ -0,0 +1,6 @@
+#if 0
+
+void
+main ()
+{
+}
diff --git a/testsuite/gsksl/errors/missing-endif-after-if-1.glsl 
b/testsuite/gsksl/errors/missing-endif-after-if-1.glsl
new file mode 100644
index 0000000..d44b830
--- /dev/null
+++ b/testsuite/gsksl/errors/missing-endif-after-if-1.glsl
@@ -0,0 +1,6 @@
+#if 1
+
+void
+main ()
+{
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]