[PATCH, committed] jit: document union types

David Malcolm dmalcolm@redhat.com
Wed Jul 1 12:42:00 GMT 2015


Committed to trunk as r225246.

gcc/jit/ChangeLog:
	* docs/topics/types.rst (gcc_jit_context_new_union_type): Add
	documentation.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
	* jit.dg/test-accessing-union.c: Add comments for use by
	gcc/jit/docs/topics/types.rst.
---
 gcc/jit/docs/topics/types.rst               | 19 +++++++++++++++++++
 gcc/testsuite/jit.dg/test-accessing-union.c |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst
index 5bfba72..41fa40e 100644
--- a/gcc/jit/docs/topics/types.rst
+++ b/gcc/jit/docs/topics/types.rst
@@ -230,3 +230,22 @@ You can model C `struct` types by creating :c:type:`gcc_jit_struct *` and
    Populate the fields of a formerly-opaque struct type.
 
    This can only be called once on a given struct type.
+
+.. function:: gcc_jit_type *\
+              gcc_jit_context_new_union_type (gcc_jit_context *ctxt,\
+                                              gcc_jit_location *loc,\
+                                              const char *name,\
+                                              int num_fields,\
+                                              gcc_jit_field **fields)
+
+     Construct a new union type, with the given name and fields.
+
+     The parameter ``name`` must be non-NULL.  It is copied, so the input
+     buffer does not need to outlive the call.
+
+     Example of use:
+
+     .. literalinclude:: ../../../testsuite/jit.dg/test-accessing-union.c
+       :start-after: /* Quote from here in docs/topics/types.rst.  */
+       :end-before: /* Quote up to here in docs/topics/types.rst.  */
+       :language: c
diff --git a/gcc/testsuite/jit.dg/test-accessing-union.c b/gcc/testsuite/jit.dg/test-accessing-union.c
index 658d1bc..15656e9 100644
--- a/gcc/testsuite/jit.dg/test-accessing-union.c
+++ b/gcc/testsuite/jit.dg/test-accessing-union.c
@@ -5,6 +5,8 @@
 
 #include "harness.h"
 
+/* Quote from here in docs/topics/types.rst.  */
+
 union int_or_float
 {
   int as_int;
@@ -77,6 +79,8 @@ create_code (gcc_jit_context *ctxt, void *user_data)
 				 as_float));
 }
 
+/* Quote up to here in docs/topics/types.rst.  */
+
 void
 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
 {
-- 
1.8.5.3



More information about the Gcc-patches mailing list