This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, committed] jit: document union types
- From: David Malcolm <dmalcolm at redhat dot com>
- To: jit at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Cc: David Malcolm <dmalcolm at redhat dot com>
- Date: Wed, 1 Jul 2015 08:55:27 -0400
- Subject: [PATCH, committed] jit: document union types
- Authentication-results: sourceware.org; auth=none
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