From 8e340c158c41ee053fd2be2f30b47e9a060515c9 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Fri, 22 Feb 2013 10:11:50 +0100 Subject: [PATCH 1/4] Fixed #1300 clang warning in SWIG_Python_ConvertPtrAndOwn. --- Lib/python/pyrun.swg | 4 ++-- Lib/swigrun.swg | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 3585e7a3f..cbb993064 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1231,10 +1231,10 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; - res = SWIG_AddCast(res); + SWIG_AddCastInplace(&res); res = SWIG_AddNewMask(res); } else { - res = SWIG_AddCast(res); + SWIG_AddCastInplace(&res); } } } diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index e5afb62c4..3f68d66d6 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -161,13 +161,20 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +SWIGINTERNINLINE int SWIG_AddCastInplace(int *r) { + if (SWIG_IsOK(*r)) { + *r = (SWIG_CastRank(*r) < SWIG_MAXCASTRANK) ? (*r + 1) : SWIG_ERROR; + } +} +SWIGINTERNINLINE int SWIG_AddCast(int r) { + SWIG_AddCastInplace(&r); + return r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ +# define SWIG_AddCastInplace(r) # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From 7acf6b5fef128de8e9ded023870006b10b4a39a8 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Mon, 25 Feb 2013 09:53:45 +0100 Subject: [PATCH 2/4] Revert "Fixed #1300 clang warning in SWIG_Python_ConvertPtrAndOwn." This reverts commit 8e340c158c41ee053fd2be2f30b47e9a060515c9. --- Lib/python/pyrun.swg | 4 ++-- Lib/swigrun.swg | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index cbb993064..3585e7a3f 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1231,10 +1231,10 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int *ptr = vptr; /* transfer the ownership to 'ptr' */ iobj->own = 0; - SWIG_AddCastInplace(&res); + res = SWIG_AddCast(res); res = SWIG_AddNewMask(res); } else { - SWIG_AddCastInplace(&res); + res = SWIG_AddCast(res); } } } diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 3f68d66d6..e5afb62c4 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -161,20 +161,13 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCastInplace(int *r) { - if (SWIG_IsOK(*r)) { - *r = (SWIG_CastRank(*r) < SWIG_MAXCASTRANK) ? (*r + 1) : SWIG_ERROR; - } -} -SWIGINTERNINLINE int SWIG_AddCast(int r) { - SWIG_AddCastInplace(&r); - return r; +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCastInplace(r) # define SWIG_AddCast # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From c23b7606cf665ce1a4e0f666f6926282971d108f Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Mon, 25 Feb 2013 11:07:42 +0100 Subject: [PATCH 3/4] MOdified only no-cast-rank version of SWIG_AddCast. --- Lib/swigrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index e5afb62c4..b3c11c136 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -168,7 +168,7 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) ((r)+0) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif From 8155e145799728eba648f63a5e3da6ab513ed63b Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Tue, 26 Feb 2013 09:26:13 +0100 Subject: [PATCH 4/4] Macro expansion to self assign is effectively ignored. --- Lib/swigrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index b3c11c136..999c87333 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -168,7 +168,7 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast(r) ((r)+0) +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif