summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/glsl/glcpp/glcpp-lex.l6
-rw-r--r--src/glsl/glcpp/tests/129-define-non-identifier.c1
-rw-r--r--src/glsl/glcpp/tests/129-define-non-identifier.c.expected2
3 files changed, 9 insertions, 0 deletions
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index cfb9f2a18be..0d4bfc8d443 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -259,6 +259,12 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
return OBJ_IDENTIFIER;
}
+<DEFINE>[^_a-zA-Z]{NONSPACE}* {
+ BEGIN INITIAL;
+ glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
+ return INTEGER_STRING;
+}
+
{HASH}undef {
yyextra->space_tokens = 0;
return HASH_UNDEF;
diff --git a/src/glsl/glcpp/tests/129-define-non-identifier.c b/src/glsl/glcpp/tests/129-define-non-identifier.c
new file mode 100644
index 00000000000..a229179f18c
--- /dev/null
+++ b/src/glsl/glcpp/tests/129-define-non-identifier.c
@@ -0,0 +1 @@
+#define 123 456
diff --git a/src/glsl/glcpp/tests/129-define-non-identifier.c.expected b/src/glsl/glcpp/tests/129-define-non-identifier.c.expected
new file mode 100644
index 00000000000..b460357fe20
--- /dev/null
+++ b/src/glsl/glcpp/tests/129-define-non-identifier.c.expected
@@ -0,0 +1,2 @@
+0:1(10): preprocessor error: #define followed by a non-identifier: 123
+0:1(10): preprocessor error: syntax error, unexpected INTEGER_STRING, expecting FUNC_IDENTIFIER or OBJ_IDENTIFIER