OSDN Git Service

glcpp: Add a test for #elif with an undefined macro.
authorCarl Worth <cworth@cworth.org>
Fri, 30 Sep 2011 05:24:18 +0000 (22:24 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 30 Sep 2011 18:44:21 +0000 (11:44 -0700)
As written, this test correctly raises an error for #elif being used
with an undefined macro (and not as an argument to "defined"). If the
preceding #if were '#if 1' then this diagnositc would correctly be
hidden. That allows code such as the following to not raise an error:

#ifndef MAYBE_UNDEFINED
#elif MAYBE_UNDEFINED < 5
...
#endif

So this test case is working as expected already. We add it here just
to improve test coverage.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Carl Worth <cworth@cworth.org>
src/glsl/glcpp/tests/098-elif-undefined.c [new file with mode: 0644]
src/glsl/glcpp/tests/098-elif-undefined.c.expected [new file with mode: 0644]

diff --git a/src/glsl/glcpp/tests/098-elif-undefined.c b/src/glsl/glcpp/tests/098-elif-undefined.c
new file mode 100644 (file)
index 0000000..52a331c
--- /dev/null
@@ -0,0 +1,3 @@
+#if 0
+#elif UNDEFINED_MACRO
+#endif
diff --git a/src/glsl/glcpp/tests/098-elif-undefined.c.expected b/src/glsl/glcpp/tests/098-elif-undefined.c.expected
new file mode 100644 (file)
index 0000000..de967ea
--- /dev/null
@@ -0,0 +1,5 @@
+0:2(22): preprocessor error: syntax error, unexpected IDENTIFIER
+0:1(7): preprocessor error: Unterminated #if
+
+
+