aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/tests
diff options
context:
space:
mode:
authorCarl Worth <[email protected]>2010-07-20 14:13:32 -0700
committerIan Romanick <[email protected]>2010-07-20 17:01:11 -0700
commit1d7e03e48e87328ce0081021dde133921b78b406 (patch)
tree6bd7be0087307fe520cd2ab672b73e48a65f145c /src/glsl/glcpp/tests
parent17f9beb6c313b41ca08984add7b76ecb84a7339e (diff)
glcpp: Fix support for nested #ifdef and nested #ifndef
Previously, if the outer #ifdef/#ifndef evaluated to false, the inner directive would not be parsed correctly, (the identifier as the subject of the #ifdef/#ifndef would inadvertently be skipped along with the other content correctly being skipped). We fix this by setting the lexing_if state in each case here. We also add a new test to the test suite to ensure that this case is tested.
Diffstat (limited to 'src/glsl/glcpp/tests')
-rw-r--r--src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c40
-rw-r--r--src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected41
2 files changed, 81 insertions, 0 deletions
diff --git a/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c
new file mode 100644
index 00000000000..f46cce4e60a
--- /dev/null
+++ b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c
@@ -0,0 +1,40 @@
+#define D1
+#define D2
+
+#define result success
+
+#ifdef U1
+#ifdef U2
+#undef result
+#define result failure
+#endif
+#endif
+result
+
+#ifndef D1
+#ifndef D2
+#undef result
+#define result failure
+#endif
+#endif
+result
+
+#undef result
+#define result failure
+#ifdef D1
+#ifdef D2
+#undef result
+#define result success
+#endif
+#endif
+result
+
+#undef result
+#define result failure
+#ifndef U1
+#ifndef U2
+#undef result
+#define result success
+#endif
+#endif
+result
diff --git a/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected
new file mode 100644
index 00000000000..3340daaa1f9
--- /dev/null
+++ b/src/glsl/glcpp/tests/067-nested-ifdef-ifndef.c.expected
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+success
+
+
+
+
+
+
+
+success
+
+
+
+
+
+
+
+
+
+success
+
+
+
+
+
+
+
+
+
+success
+