glcpp: Add testing for no space between macro name and replacement list

GCC's preprocessor accepts a macro definition where there is no space between
the macro's identifier name and the replacementlist. (GCC does emit a "missing
space" warning that we don't, but that's fine.)

This is an exhaustive test that verifies that all legal GLSL characters that
could possibly be interpreted as separating the macro name from the
replacement list are interpreted as such. So the testing here includes all
valid GLSL symbols except for:

  * Characters that can be part of an identifier (a-z, A-Z, 0-9, _)

  * Backslash, (allowed only as line continuation)

  * Hash, (allowed only to introduce pre-processor directive, or as part of a
           paste operator in a replacement list---but not as first token of
           replacement list)

  * Space characters (since the point of the testing is to have missing space)

  * Left parenthesis (which would indicate a function-like macro)

v2 (Ken): Move to src/compiler, renumber tests.

Reviewed-by: Kenneth Graunke <>
diff --git a/src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c b/src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c
new file mode 100644
index 0000000..9ef7f7c
--- /dev/null
+++ b/src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c
@@ -0,0 +1,58 @@
+/* The GLSL specification is not specific about how to handle a non-space
+ * character separating a macro identifier from the replacement list. It says
+ * only "as is standard for C++ preprocessors". GCC accepts these and warns of
+ * "missing whitespace". So we'll accept these, (though we don't warn).
+ *
+ * Note: 'O' is intentionally omitted to leave room for "octothorpe" if we
+ *       decide it should be legal to use a hash here, (in fact, hash has no
+ *       legal use as the first token in a macro replacement list, but one
+ *       could argue that that could still be allowed if the macro were never
+ *       instantiated).
+ */
+#define A& ampersand
+#define B! bang
+#define C, comma
+#define D/ divider
+#define E= equals
+#define F. full stop
+#define G> greater than
+#define H- hyphen
+#define I+ incrementor
+#define J[ JSON array
+#define K} kurly brace?
+#define L< less than
+#define M{ moustache
+#define N^ nose
+#define P) parenthesis (right)
+#define Q? question mark
+#define R% ratio indicator
+#define S] square bracket (right)
+#define T~ tilde
+#define U: umlaut?
+#define V| vertical bar
+#define W; wink
+#define X* X (as multiplication)
diff --git a/src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c.expected b/src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c.expected
new file mode 100644
index 0000000..1403703
--- /dev/null
+++ b/src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c.expected
@@ -0,0 +1,58 @@
+& ampersand
+! bang
+, comma
+/ divider
+= equals
+. full stop
+> greater than
+- hyphen
++ incrementor
+[ JSON array
+} kurly brace?
+< less than
+{ moustache
+^ nose
+) parenthesis (right)
+? question mark
+% ratio indicator
+] square bracket (right)
+~ tilde
+: umlaut?
+| vertical bar
+; wink
+* X (as multiplication)