[gtk+/wip/otte/shader: 97/101] gskslpreprocessor: Error if #endif is missing
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/shader: 97/101] gskslpreprocessor: Error if #endif is missing
- Date: Fri, 27 Oct 2017 12:30:20 +0000 (UTC)
commit 5e2195950ccad3fe9c457ecf2340f129c292a610
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]