aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Worth <[email protected]>2014-08-05 16:33:02 -0700
committerKenneth Graunke <[email protected]>2017-01-04 14:40:48 -0800
commit6c8762400d0d7b18250d8e1663d8812ca0811023 (patch)
treed0850e1593327bb735c12b37fddbafd613625ce3
parent36b5f1d200bf1f24f562fd3c441c4322f2ff5029 (diff)
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 <[email protected]>
-rw-r--r--src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c58
-rw-r--r--src/compiler/glsl/glcpp/tests/147-define-macro-no-space.c.expected58
2 files changed, 116 insertions, 0 deletions
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 00000000000..9ef7f7cc769
--- /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)
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+K
+L
+M
+N
+P
+Q
+R
+S
+T
+U
+V
+W
+X
+
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 00000000000..1403703ea8c
--- /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)
+