Visual C++ warning fixes

This commit is contained in:
William S Fulton 2023-12-30 13:49:40 +00:00
parent 462bde02fe
commit daeaa6ab11
10 changed files with 37 additions and 10 deletions

View File

@ -11,7 +11,7 @@
%inline %{
#if defined(_MSC_VER)
#pragma warning( disable : 4250) // warning C4250: 'D' : inherits 'B::B::foo' via dominance
#pragma warning(disable : 4250) // warning C4250: 'D' : inherits 'B::B::foo' via dominance
#endif
struct A
{

View File

@ -1,5 +1,11 @@
%module assign_const
%{
#if defined(_MSC_VER)
#pragma warning(disable : 4351) // warning C4351: new behavior: elements of array 'AssignArray::ArrayMember' will be default initialized
#endif
%}
// Similar to assign_reference.i testcase but reference member variables replaced by const members
%rename(Assign) *::operator=;

View File

@ -41,8 +41,8 @@ double d_array[12 % 9];
*/
#define XX (2<(2<2))
#define YY (2>(2>2))
int xx() { return XX; }
int yy() { return YY; }
int xx() { return (int)(XX); }
int yy() { return (int)(YY); }
/* sizeof didn't work on an expression before SWIG 4.1.0 except for cases where
* the expression was in parentheses and looked syntactically like a type (so

View File

@ -1,5 +1,11 @@
%module cpp11_copyctor_delete
%{
#if defined(_MSC_VER)
#pragma warning(disable : 4624) // warning C4624: 'StackOnlyDerived1': destructor was implicitly defined as deleted
#endif
%}
%inline %{
struct DeletedPublic1 {
DeletedPublic1() = delete;

View File

@ -3,6 +3,13 @@
*/
%module cpp11_decltype
%{
#if defined(_MSC_VER)
#pragma warning(disable : 4804) // warning C4804: '-': unsafe use of type 'bool' in operation
// For: decltype(-false) should_be_int2;
#endif
%}
#ifdef SWIGGO
// FIXME: SWIG/Go tries to wrap this by generating code which tries to
// assign a const char* value to a char* variable.

View File

@ -3,6 +3,12 @@
%include <std_string.i>
%include <exception.i>
#ifdef SWIGCSHARP
#define TYPEMAP_OUT_INIT $result = 0;
#else
#define TYPEMAP_OUT_INIT
#endif
%typemap(in) Foo* foo
{
$1 = new Foo;
@ -14,6 +20,7 @@
}
%typemap(out) Foo* trigger_internal_swig_exception
{
TYPEMAP_OUT_INIT
if ($1 == NULL) {
SWIG_exception(SWIG_RuntimeError, "Let's see how the bindings manage this exception!");
#ifdef SWIG_fail
@ -24,6 +31,7 @@
}
%typemap(out) Foo trigger_internal_swig_exception
{
TYPEMAP_OUT_INIT
SWIG_exception(SWIG_RuntimeError, "Let's see how the bindings manage this exception!");
#ifdef SWIG_fail
SWIG_fail;

View File

@ -783,7 +783,7 @@ namespace swig {
}
static bool check(PyObject *obj) {
int ret = false;
bool ret = false;
SwigVar_PyObject iter = PyObject_GetIter(obj);
if (iter) {
SwigVar_PyObject item = PyIter_Next(iter);

View File

@ -39,7 +39,7 @@
}
static bool check(PyObject *obj) {
int ret = false;
bool ret = false;
SwigVar_PyObject iter = PyObject_GetIter(obj);
if (iter) {
SwigVar_PyObject item = PyIter_Next(iter);

View File

@ -4455,12 +4455,12 @@ templateparameter : templcpptype def_args {
/* A 'class T' parameter */
const char *t = Strchr(type, ' ');
Setattr(p, "name", t + 1);
Setattr(p, "type", NewStringWithSize(type, t - Char(type)));
Setattr(p, "type", NewStringWithSize(type, (int)(t - Char(type))));
} else if ((Strncmp(type, "v.class ", 8) == 0) || (Strncmp(type, "v.typename ", 11) == 0)) {
/* Variadic template args */
const char *t = Strchr(type, ' ');
Setattr(p, "name", t + 1);
Setattr(p, "type", NewStringWithSize(type, t - Char(type)));
Setattr(p, "type", NewStringWithSize(type, (int)(t - Char(type))));
}
}
}

View File

@ -429,7 +429,7 @@ static Parm *partial_arg(const SwigType *type, const SwigType *partialtype) {
if (c) {
int suffix_length;
int prefix_length = c - cp;
int prefix_length = (int)(c - cp);
int type_length = Len(type);
const char *suffix = c;
String *prefix = NewStringWithSize(cp, prefix_length);
@ -437,8 +437,8 @@ static Parm *partial_arg(const SwigType *type, const SwigType *partialtype) {
if (!isdigit((int)*suffix))
break;
}
parmname = NewStringWithSize(c, suffix - c); /* $1, $2 etc */
suffix_length = strlen(suffix);
parmname = NewStringWithSize(c, (int)(suffix - c)); /* $1, $2 etc */
suffix_length = (int)strlen(suffix);
assert(Strstr(type, prefix) == Char(type)); /* check that the start of both types match */
assert(strcmp(Char(type) + type_length - suffix_length, suffix) == 0); /* check that the end of both types match */
parmtype = NewStringWithSize(Char(type) + prefix_length, type_length - suffix_length - prefix_length);