aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAntoni Boucher <bouanto@zoho.com>2022-06-09 21:37:23 -0400
committerAntoni Boucher <bouanto@zoho.com>2022-06-09 21:50:25 -0400
commit5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc (patch)
tree687d8436b82fc8df2733b89222011f59f27d5827 /gcc
parente3bba42fb5d64d2b49a9cd3511f8f57e36d46dfe (diff)
downloadgcc-5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc.zip
gcc-5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc.tar.gz
gcc-5940b4e59f8e198dbf7e8b733561ef72a9ba2cbc.tar.bz2
libgccjit: Support getting the size of a float [PR105829]
2022-06-09 Antoni Boucher <bouanto@zoho.com> gcc/jit/ PR jit/105829 * libgccjit.cc: Add support for floating-point types in gcc_jit_type_get_size. gcc/testsuite/ PR jit/105829 * jit.dg/test-types.c: Add tests for gcc_jit_type_get_size.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/jit/libgccjit.cc4
-rw-r--r--gcc/testsuite/jit.dg/test-types.c3
2 files changed, 5 insertions, 2 deletions
diff --git a/gcc/jit/libgccjit.cc b/gcc/jit/libgccjit.cc
index cc6486c..0e76097 100644
--- a/gcc/jit/libgccjit.cc
+++ b/gcc/jit/libgccjit.cc
@@ -545,8 +545,8 @@ gcc_jit_type_get_size (gcc_jit_type *type)
{
RETURN_VAL_IF_FAIL (type, -1, NULL, NULL, "NULL type");
RETURN_VAL_IF_FAIL
- (type->is_int (), -1, NULL, NULL,
- "only getting the size of an integer type is supported for now");
+ (type->is_int () || type->is_float (), -1, NULL, NULL,
+ "only getting the size of integer or floating-point types is supported for now");
return type->get_size ();
}
diff --git a/gcc/testsuite/jit.dg/test-types.c b/gcc/testsuite/jit.dg/test-types.c
index 6836597..a01944e 100644
--- a/gcc/testsuite/jit.dg/test-types.c
+++ b/gcc/testsuite/jit.dg/test-types.c
@@ -489,4 +489,7 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
CHECK (gcc_jit_compatible_types (
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_LONG),
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT64_T)));
+
+ CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_FLOAT)), sizeof (float));
+ CHECK_VALUE (gcc_jit_type_get_size (gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE)), sizeof (double));
}