summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-02-05 15:03:04 -0800
committerJason Ekstrand <[email protected]>2016-02-05 15:03:44 -0800
commit741744f691d6ef63e9f9a4c03136f969f2ffb0bf (patch)
tree7c9192a0648c2d90bb08efbc21ebcb7a6e2b873a /src/compiler/glsl/glcpp/tests/142-defined-within-macro.c
parent9645b8eb1f1b79e537ad8ddb683507df7bc9da58 (diff)
parenteb63640c1d38a200a7b1540405051d3ff79d0d8a (diff)
Merge commit mesa-public/master into vulkan
This pulls in the patches that move all of the compiler stuff around
Diffstat (limited to 'src/compiler/glsl/glcpp/tests/142-defined-within-macro.c')
-rw-r--r--src/compiler/glsl/glcpp/tests/142-defined-within-macro.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c b/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c
new file mode 100644
index 00000000000..b60c04232a6
--- /dev/null
+++ b/src/compiler/glsl/glcpp/tests/142-defined-within-macro.c
@@ -0,0 +1,94 @@
+/* Macro using defined with a hard-coded identifier (no parentheses) */
+#define is_foo_defined defined /*...*/ foo
+#undef foo
+#if is_foo_defined
+failure
+#else
+success
+#endif
+#define foo
+#if is_foo_defined
+success
+#else
+failure
+#endif
+
+/* Macro using defined with a hard-coded identifier within parentheses */
+#define is_foo_defined_parens defined /*...*/ ( /*...*/ foo /*...*/ ) //
+#define foo
+#if is_foo_defined_parens
+success
+#else
+failure
+#endif
+#undef foo
+#if is_foo_defined_parens
+failure
+#else
+success
+#endif
+
+/* Macro using defined with an argument identifier (no parentheses) */
+#define is_defined(arg) defined /*...*/ arg
+#define foo bar
+#undef bar
+#if is_defined(foo)
+failure
+#else
+success
+#endif
+#define bar bar
+#if is_defined(foo)
+success
+#else
+failure
+#endif
+
+/* Macro using defined with an argument identifier within parentheses */
+#define is_defined_parens(arg) defined /*...*/ ( /*...*/ arg /*...*/ ) //
+#define foo bar
+#define bar bar
+#if is_defined_parens(foo)
+success
+#else
+failure
+#endif
+#undef bar
+#if is_defined_parens(foo)
+failure
+#else
+success
+#endif
+
+/* Multiple levels of macro resulting in defined */
+#define X defined A && Y
+#define Y defined B && Z
+#define Z defined C
+#define A
+#define B
+#define C
+#if X
+success
+#else
+failure
+#endif
+#undef A
+#if X
+failure
+#else
+success
+#endif
+#define A
+#undef B
+#if X
+failure
+#else
+success
+#endif
+#define B
+#undef C
+#if X
+failure
+#else
+success
+#endif