[Mesa-dev] [PATCH 1/3] glcpp: Reject #version and #line not followed by whitespace
Matt Turner
mattst88 at gmail.com
Mon Nov 26 14:30:17 PST 2012
Fixes part of es3conform's preprocess16_frag test.
---
src/glsl/glcpp/glcpp-lex.l | 4 ++--
.../glcpp/tests/108-no-space-after-hash-version.c | 1 +
.../108-no-space-after-hash-version.c.expected | 2 ++
.../glcpp/tests/109-no-space-after-hash-line.c | 1 +
.../tests/109-no-space-after-hash-line.c.expected | 2 ++
5 files changed, 8 insertions(+), 2 deletions(-)
create mode 100644 src/glsl/glcpp/tests/108-no-space-after-hash-version.c
create mode 100644 src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected
create mode 100644 src/glsl/glcpp/tests/109-no-space-after-hash-line.c
create mode 100644 src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 783c545..4f0dd34 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -120,7 +120,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
return SPACE;
}
-{HASH}version {
+{HASH}version{HSPACE}+ {
yylval->str = ralloc_strdup (yyextra, yytext);
yyextra->space_tokens = 0;
return HASH_VERSION;
@@ -135,7 +135,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
return OTHER;
}
-{HASH}line {
+{HASH}line{HSPACE}+ {
return HASH_LINE;
}
diff --git a/src/glsl/glcpp/tests/108-no-space-after-hash-version.c b/src/glsl/glcpp/tests/108-no-space-after-hash-version.c
new file mode 100644
index 0000000..0ce36f2
--- /dev/null
+++ b/src/glsl/glcpp/tests/108-no-space-after-hash-version.c
@@ -0,0 +1 @@
+#version110
diff --git a/src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected b/src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected
new file mode 100644
index 0000000..da4544a
--- /dev/null
+++ b/src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected
@@ -0,0 +1,2 @@
+0:1(3): preprocessor error: Invalid tokens after #
+
diff --git a/src/glsl/glcpp/tests/109-no-space-after-hash-line.c b/src/glsl/glcpp/tests/109-no-space-after-hash-line.c
new file mode 100644
index 0000000..f52966a
--- /dev/null
+++ b/src/glsl/glcpp/tests/109-no-space-after-hash-line.c
@@ -0,0 +1 @@
+#line2
diff --git a/src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected b/src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected
new file mode 100644
index 0000000..da4544a
--- /dev/null
+++ b/src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected
@@ -0,0 +1,2 @@
+0:1(3): preprocessor error: Invalid tokens after #
+
--
1.7.8.6
More information about the mesa-dev
mailing list