This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[jit] Improve error message in gcc_jit_function_new_local


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  <dmalcolm@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  <dmalcolm@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]