summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/tests
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2012-11-06 10:59:30 -0800
committerMatt Turner <[email protected]>2012-11-09 14:33:08 -0800
commit060e69679925f171cfcc2a5f84fab1d833a7e804 (patch)
tree6061b0f7d878ef3c0d74904b290b50f9b8b997e5 /src/glsl/glcpp/tests
parentafcaa03f7ea6918ce7a9cab1b02ec97e05309a63 (diff)
glcpp: Reject garbage after #else and #endif tokens
Previously we were accepting garbage after #else and #endif tokens when the previous preprocessor conditional evaluated to false (eg, #if 0). When the preprocessor hits a false conditional, it switches the lexer into the SKIP state, in which it ignores non-control tokens. The parser pops the SKIP state off the stack when it reaches the associated #elif, #else, or #endif. Unfortunately, that meant that it only left the SKIP state after the lexing the entire line containing the #token and thus would accept garbage after the #token. To fix this we use a mid-rule, which is executed immediately after the #token is parsed. NOTE: This is a candidate for the stable branch Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56442 Fixes: preprocess17_frag.test from oglconform Reviewed-by: Carl Worth <[email protected]> (glcpp-parse.y) Acked-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl/glcpp/tests')
-rw-r--r--src/glsl/glcpp/tests/102-garbage-after-endif.c2
-rw-r--r--src/glsl/glcpp/tests/102-garbage-after-endif.c.expected2
-rw-r--r--src/glsl/glcpp/tests/103-garbage-after-else.c3
-rw-r--r--src/glsl/glcpp/tests/103-garbage-after-else.c.expected4
4 files changed, 11 insertions, 0 deletions
diff --git a/src/glsl/glcpp/tests/102-garbage-after-endif.c b/src/glsl/glcpp/tests/102-garbage-after-endif.c
new file mode 100644
index 00000000000..301779eb948
--- /dev/null
+++ b/src/glsl/glcpp/tests/102-garbage-after-endif.c
@@ -0,0 +1,2 @@
+#if 0
+#endif garbage
diff --git a/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected b/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected
new file mode 100644
index 00000000000..d9f3bdc9465
--- /dev/null
+++ b/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected
@@ -0,0 +1,2 @@
+0:2(8): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE
+
diff --git a/src/glsl/glcpp/tests/103-garbage-after-else.c b/src/glsl/glcpp/tests/103-garbage-after-else.c
new file mode 100644
index 00000000000..c460feadf57
--- /dev/null
+++ b/src/glsl/glcpp/tests/103-garbage-after-else.c
@@ -0,0 +1,3 @@
+#if 0
+#else garbage
+#endif
diff --git a/src/glsl/glcpp/tests/103-garbage-after-else.c.expected b/src/glsl/glcpp/tests/103-garbage-after-else.c.expected
new file mode 100644
index 00000000000..f9f5f1976f7
--- /dev/null
+++ b/src/glsl/glcpp/tests/103-garbage-after-else.c.expected
@@ -0,0 +1,4 @@
+0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE
+0:1(7): preprocessor error: Unterminated #if
+
+