summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/tests
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2013-12-17 16:37:33 +0100
committerCarl Worth <[email protected]>2014-01-02 14:22:58 -0800
commiteb212c5a302f0122a13b36dfdf07e91f951ae2e7 (patch)
tree82582edde6697d40e7496d1e994fea21cfdf6027 /src/glsl/glcpp/tests
parent6005e9cb283214cd57038c7c5e7758ba72ec6ac2 (diff)
glcpp: error on multiple #else/#elif directives
The preprocessor currently accepts multiple else/elif-groups per if-section. The GLSL-preprocessor is defined by the C++ specification, which defines the following parse-rule: if-section: if-group elif-groups(opt) else-group(opt) endif-line This clearly only allows a single else-group, that has to come after any elif-groups. So let's modify the code to follow the specification. Add test to prevent regressions. Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Carl Worth <[email protected]> Cc: 10.0 <[email protected]>
Diffstat (limited to 'src/glsl/glcpp/tests')
-rw-r--r--src/glsl/glcpp/tests/118-multiple-else.c6
-rw-r--r--src/glsl/glcpp/tests/118-multiple-else.c.expected8
-rw-r--r--src/glsl/glcpp/tests/119-elif-after-else.c6
-rw-r--r--src/glsl/glcpp/tests/119-elif-after-else.c.expected8
4 files changed, 28 insertions, 0 deletions
diff --git a/src/glsl/glcpp/tests/118-multiple-else.c b/src/glsl/glcpp/tests/118-multiple-else.c
new file mode 100644
index 00000000000..62ad49cf7bb
--- /dev/null
+++ b/src/glsl/glcpp/tests/118-multiple-else.c
@@ -0,0 +1,6 @@
+#if 0
+#else
+int foo;
+#else
+int bar;
+#endif
diff --git a/src/glsl/glcpp/tests/118-multiple-else.c.expected b/src/glsl/glcpp/tests/118-multiple-else.c.expected
new file mode 100644
index 00000000000..eaec4815076
--- /dev/null
+++ b/src/glsl/glcpp/tests/118-multiple-else.c.expected
@@ -0,0 +1,8 @@
+0:4(1): preprocessor error: multiple #else
+
+
+int foo;
+
+int bar;
+
+
diff --git a/src/glsl/glcpp/tests/119-elif-after-else.c b/src/glsl/glcpp/tests/119-elif-after-else.c
new file mode 100644
index 00000000000..9b9e9233bcb
--- /dev/null
+++ b/src/glsl/glcpp/tests/119-elif-after-else.c
@@ -0,0 +1,6 @@
+#if 0
+#else
+int foo;
+#elif 0
+int bar;
+#endif
diff --git a/src/glsl/glcpp/tests/119-elif-after-else.c.expected b/src/glsl/glcpp/tests/119-elif-after-else.c.expected
new file mode 100644
index 00000000000..33f05136158
--- /dev/null
+++ b/src/glsl/glcpp/tests/119-elif-after-else.c.expected
@@ -0,0 +1,8 @@
+0:4(1): preprocessor error: #elif after #else
+
+
+int foo;
+
+int bar;
+
+