[Piglit] [PATCH 1/2] glsl: Test that anonymous structure declarators are not allowed

Ian Romanick idr at freedesktop.org
Wed Jun 26 17:25:16 PDT 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Both GLSL ES 1.00 and GLSL 1.20 disallow "anonymous structures."  Each
spec explains this term, and it's not what I had previously thought.  It
is valid to have a struct that has no name (e.g., struct { int x }
foo;).  It is not valid to have a struct in a declarator without a
variable name.  Some flavors of C allow this inside structures.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Cc: Tom Gall <tom.gall at linaro.org>
---
 .../anonymous-struct.vert                          | 31 ++++++++++++++++++
 .../anonymous-struct.vert                          | 38 ++++++++++++++++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 tests/spec/glsl-1.20/compiler/structure-and-array-operations/anonymous-struct.vert
 create mode 100644 tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/anonymous-struct.vert

diff --git a/tests/spec/glsl-1.20/compiler/structure-and-array-operations/anonymous-struct.vert b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/anonymous-struct.vert
new file mode 100644
index 0000000..5cf297c
--- /dev/null
+++ b/tests/spec/glsl-1.20/compiler/structure-and-array-operations/anonymous-struct.vert
@@ -0,0 +1,31 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.20
+ * [end config]
+ *
+ * From section 4.1.8 ("Structures") of the GLSL 1.20 spec:
+ *
+ *     "Anonymous structures are not supported. Embedded structures
+ *     are not supported.
+ *
+ *         struct S { float f; };
+ *
+ *         struct T {
+ *             S;              // Error: anonymous structures disallowed
+ *             struct { ... }; // Error: embedded structures disallowed
+ *             S s;            // Okay: nested structures with name are allowed
+ *         };"
+ */
+#version 120
+
+struct S { float f; };
+
+struct T {
+    S;              // Error: anonymous structures disallowed
+    S s;            // Okay: nested structures with name are allowed
+};
+
+void main()
+{
+    gl_Position = vec4(1);
+}
diff --git a/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/anonymous-struct.vert b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/anonymous-struct.vert
new file mode 100644
index 0000000..a7c3a6f
--- /dev/null
+++ b/tests/spec/glsl-es-1.00/compiler/structure-and-array-operations/anonymous-struct.vert
@@ -0,0 +1,38 @@
+/* [config]
+ * expect_result: fail
+ * glsl_version: 1.00
+ * [end config]
+ *
+ * From section 4.1.8 ("Structures") of the GLSL ES 1.00 spec:
+ *
+ *     "Anonymous structure declarators (member declaration whose type is a
+ *     structure but has no declarator) are not supported.
+ *
+ *         struct S
+ *         {
+ *             int x;
+ *         };
+ *
+ *         struct T
+ *         {
+ *             S;
+ *             int y;
+ *         };"
+ */
+#version 100
+
+struct S
+{
+    int x;
+};
+
+struct T
+{
+    S;
+    int y;
+};
+
+void main()
+{
+    gl_Position = vec4(1);
+}
-- 
1.8.1.4



More information about the Piglit mailing list