Committed to dmalcolm/jit:

gcc/jit/
        * libgccjit.c (gcc_jit_function_new_local): Use a more clear
        error message for the case where someone tries to add a local
        to a function imported from elsewhere.
---
 gcc/jit/ChangeLog.jit | 6 ++++++
 gcc/jit/libgccjit.c   | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index e16902d..df08834 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,5 +1,11 @@
 2013-10-21  David Malcolm  <dmalc...@redhat.com>
 
+       * libgccjit.c (gcc_jit_function_new_local): Use a more clear
+       error message for the case where someone tries to add a local
+       to a function imported from elsewhere.
+
+2013-10-21  David Malcolm  <dmalc...@redhat.com>
+
        * TODO.rst ("the C unary prefix "&" operator"): Remove completed item.
        * internal-api.c (gcc::jit::lvalue::get_address): New.
        * internal-api.h (gcc::jit::lvalue::get_address): New.
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 8d77761..40ac98d 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -544,7 +544,10 @@ gcc_jit_function_new_local (gcc_jit_function *func,
                            gcc_jit_type *type,
                            const char *name)
 {
-  RETURN_NULL_IF_NOT_FUNC_DEFINITION (func);
+  RETURN_NULL_IF_FAIL (func, NULL, "NULL function");
+  RETURN_NULL_IF_FAIL (func->get_kind () != GCC_JIT_FUNCTION_IMPORTED,
+                      NULL,
+                      "Cannot add locals to an imported function");
   RETURN_NULL_IF_FAIL (type, NULL, "NULL type");
   RETURN_NULL_IF_FAIL (name, NULL, "NULL name");
 
-- 
1.7.11.7

Reply via email to