Fix testsuite SWIG warnings; enable SWIG -Werror

SWIG/mzscheme (aka racket) is excluded for now as it currently has a lot
of testsuite warnings and is slated for removal in 4.4.0 anyway.

Closes #3034
This commit is contained in:
Olly Betts 2024-07-20 07:52:18 +12:00
parent ce6d2dd11e
commit 0b4496a735
37 changed files with 165 additions and 6 deletions

View File

@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.4.0 (in progress) Version 4.4.0 (in progress)
=========================== ===========================
2024-10-22: olly
#3034 SWIG's testsuite is now free of SWIG warnings for all target
languages except mzscheme and the SWIG -Werror option is now
enabled automatically to ensure this doesn't regress.
2024-10-22: olly 2024-10-22: olly
#2998 Drop support for specifying SWIG's internal type string #2998 Drop support for specifying SWIG's internal type string
representation in interface files. This "secret developer feature" representation in interface files. This "secret developer feature"

View File

@ -104,6 +104,9 @@ include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Suppress warnings about experimental status and unsupported features -- there are just too many of those for now for these warnings to be useful. # Suppress warnings about experimental status and unsupported features -- there are just too many of those for now for these warnings to be useful.
SWIGOPT += -w524 -w761 SWIGOPT += -w524 -w761

View File

@ -2,6 +2,13 @@
// %constant and struct // %constant and struct
#ifdef SWIGGUILE
// Suppress warnings for constants SWIG/Guile doesn't currently handle.
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) TYPE1_CONSTANT1;
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) TYPE1_CONSTANT2;
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) TYPE1CFPTR1DEF_CONSTANT1;
#endif
#ifdef SWIGOCAML #ifdef SWIGOCAML
%warnfilter(SWIGWARN_PARSE_KEYWORD) val; %warnfilter(SWIGWARN_PARSE_KEYWORD) val;
#endif #endif

View File

@ -8,6 +8,8 @@
%ignore addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const; %ignore addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const;
// SWIG/C doesn't currently support wrapping rvalue reference return types. // SWIG/C doesn't currently support wrapping rvalue reference return types.
%ignore SomeStruct::output(short); %ignore SomeStruct::output(short);
#elif defined SWIGGO
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) output_rvalueref;
#endif #endif
%inline %{ %inline %{

View File

@ -1,5 +1,10 @@
%module cpp11_assign_rvalue_reference %module cpp11_assign_rvalue_reference
#if defined SWIGGO
// Several: Warning 507: No Go typemap defined for int &&
# pragma SWIG nowarn=SWIGWARN_LANG_NATIVE_UNIMPL
#endif
// Copy of assign_reference.i testcase replacing reference member variables with rvalue reference member variables // Copy of assign_reference.i testcase replacing reference member variables with rvalue reference member variables
%rename(Assign) *::operator=; %rename(Assign) *::operator=;

View File

@ -1,7 +1,19 @@
%module cpp11_brackets_expression %module cpp11_brackets_expression
#ifdef SWIGGUILE
// Suppress warnings SWIG/Guile emits because these constants have type size_t
// which we don't show SWIG a definition of.
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) Piece::kOk2;
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) Piece::SimpleAsYouExpect123;
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) Piece::SimpleJust123;
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) Piece::AsYouExpect123;
%warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE,SWIGWARN_TYPEMAP_CONST_UNDEF) Piece::kMaxSize;
%warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE,SWIGWARN_TYPEMAP_CONST_UNDEF) Piece::Just123;
#else
%warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE) Piece::kMaxSize; %warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE) Piece::kMaxSize;
%warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE) Piece::Just123; %warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE) Piece::Just123;
#endif
%warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE) ::kMaxSizeGlobal; %warnfilter(SWIGWARN_PARSE_ASSIGNED_VALUE) ::kMaxSizeGlobal;
%inline %{ %inline %{

View File

@ -4,6 +4,11 @@
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&); %warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::trivial(trivial&&);
%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&); %warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED, SWIGWARN_LANG_OVERLOAD_SHADOW) trivial::operator =(trivial&&);
#if defined SWIGGO
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) trivial&&;
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) moveonly&&;
#endif
%rename(Assignment) *::operator=; %rename(Assignment) *::operator=;
%inline %{ %inline %{

View File

@ -2,7 +2,9 @@
%include "cpp11_move_only_helper.i" %include "cpp11_move_only_helper.i"
#if defined(SWIGOCAML) #if defined(SWIGGO)
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) MoveOnly&&;
#elif defined(SWIGOCAML)
%rename(valu) val; %rename(valu) val;
#endif #endif

View File

@ -1,6 +1,11 @@
// This testcase checks whether SWIG correctly parses C++11 rvalue references. // This testcase checks whether SWIG correctly parses C++11 rvalue references.
%module cpp11_rvalue_reference %module cpp11_rvalue_reference
#if defined SWIGGO
// Several: Warning 507: No Go typemap defined for int &&
# pragma SWIG nowarn=SWIGWARN_LANG_NATIVE_UNIMPL
#endif
%inline %{ %inline %{
#include <utility> #include <utility>
class A { class A {

View File

@ -2,6 +2,11 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) globalrrval; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) globalrrval;
#if defined SWIGGO
// Several: Warning 507: No Go typemap defined for int &&
# pragma SWIG nowarn=SWIGWARN_LANG_NATIVE_UNIMPL
#endif
// This testcase tests lots of different places that rvalue reference syntax can be used // This testcase tests lots of different places that rvalue reference syntax can be used
%typemap(in) Something && "/*in Something && typemap*/" %typemap(in) Something && "/*in Something && typemap*/"

View File

@ -2,6 +2,12 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
#if defined SWIGGO
// Several: Warning 507: No Go typemap defined for int &&
// and other rvalue reference types
# pragma SWIG nowarn=SWIGWARN_LANG_NATIVE_UNIMPL
#endif
%inline %{ %inline %{
#include <utility> #include <utility>
struct Thing {}; struct Thing {};

View File

@ -2,6 +2,10 @@
// Testcase for testing rvalue reference input typemaps which assume the object is moved during a function call // Testcase for testing rvalue reference input typemaps which assume the object is moved during a function call
#if defined SWIGGO
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) MovableCopyable&&;
#endif
%include "cpp11_move_only_helper.i" %include "cpp11_move_only_helper.i"
%catches(std::string) MovableCopyable::check_numbers_match; %catches(std::string) MovableCopyable::check_numbers_match;

View File

@ -3,7 +3,10 @@
// Testing templated methods in a template // Testing templated methods in a template
// Including variadic templated method reported in https://github.com/swig/swig/issues/2794 // Including variadic templated method reported in https://github.com/swig/swig/issues/2794
#if defined(SWIGLUA) || defined(SWIGOCAML) #if defined(SWIGGO)
// Several: Warning 507: No Go typemap defined for eprosima::fastrtps::rtps::octet &&
# pragma SWIG nowarn=SWIGWARN_LANG_NATIVE_UNIMPL
#elif defined(SWIGLUA) || defined(SWIGOCAML)
%rename(end_renamed) end; %rename(end_renamed) end;
%rename(begin_renamed) begin; %rename(begin_renamed) begin;
#endif #endif

View File

@ -2,6 +2,16 @@
// Note: this testcase is also used by cpp11_director_using_constructor.i // Note: this testcase is also used by cpp11_director_using_constructor.i
#ifdef SWIGLUA
// Lua does now have a separate integer type, but didn't used to
// and SWIG doesn't yet know about it (see #1918) so for now suppress
// warnings about functions with overloads on int vs double, etc.
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) TemplateConstructor1Base::TemplateConstructor1Base(double,char const *);
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) TemplateConstructor1Derived::TemplateConstructor1Derived(double,char const *);
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) TemplateConstructor1Base::TemplateConstructor1Base(double,char const *);
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) TemplateConstructor1Derived::TemplateConstructor1Derived(double,char const *);
#endif
%inline %{ %inline %{
// Public base constructors // Public base constructors
struct PublicBase1 { struct PublicBase1 {

View File

@ -1,5 +1,9 @@
%module cpp11_variadic_function_templates %module cpp11_variadic_function_templates
#if defined SWIGGO
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) EmplaceContainer::emplace;
#endif
// Some tests for variadic function templates // Some tests for variadic function templates
%inline %{ %inline %{
class A { class A {

View File

@ -20,6 +20,11 @@
SWIGWARN_PHP_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE,
SWIGWARN_RUBY_MULTIPLE_INHERITANCE) LotsInherit; SWIGWARN_RUBY_MULTIPLE_INHERITANCE) LotsInherit;
#if defined SWIGGO
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) ParmsPtrRValueRef;
%warnfilter(SWIGWARN_LANG_NATIVE_UNIMPL) ParmsRValueRef;
#endif
//////////////////////// ////////////////////////
// Variadic templates // // Variadic templates //
//////////////////////// ////////////////////////

View File

@ -58,6 +58,9 @@ SWIGOPT += -namespace $*Namespace
CSHARPFLAGSSPECIAL = CSHARPFLAGSSPECIAL =
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
complextest.cpptest: CSHARPFLAGSSPECIAL = -r:System.Numerics.dll complextest.cpptest: CSHARPFLAGSSPECIAL = -r:System.Numerics.dll
csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe

View File

@ -56,6 +56,9 @@ SRCDIR = ../$(srcdir)/
TARGETSUFFIX = _wrap TARGETSUFFIX = _wrap
SWIGOPT+=-splitproxy -package $* SWIGOPT+=-splitproxy -package $*
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Rules for the different types of tests # Rules for the different types of tests
%.cpptest: %.cpptest:
$(setup) $(setup)

View File

@ -32,6 +32,9 @@ include $(srcdir)/../common.mk
INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
.SUFFIXES: .cpptest .ctest .multicpptest .SUFFIXES: .cpptest .ctest .multicpptest
# Rules for the different types of tests # Rules for the different types of tests

View File

@ -30,6 +30,9 @@ include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile INCLUDES += -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/guile
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
%.multicpptest: SWIGOPT += $(GUILE_RUNTIME) %.multicpptest: SWIGOPT += $(GUILE_RUNTIME)

View File

@ -78,6 +78,9 @@ JAVA_PACKAGE = $*
JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE) JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT) SWIGOPT += $(JAVA_PACKAGEOPT)
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
cpp17_nspace_nested_namespaces.%: JAVA_PACKAGE = $*Package cpp17_nspace_nested_namespaces.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package director_nspace.%: JAVA_PACKAGE = $*Package

View File

@ -55,6 +55,9 @@ endif
include $(srcdir)/../common.mk include $(srcdir)/../common.mk
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
_setup = \ _setup = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(ECHO_PROGRESS) "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \ $(ECHO_PROGRESS) "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \

View File

@ -1,6 +1,12 @@
%module li_std_string %module li_std_string
%include <std_string.i> %include <std_string.i>
#ifdef SWIGGUILE
// Suppress warnings for constants SWIG/Guile doesn't currently handle.
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) MY_STRING;
%warnfilter(SWIGWARN_TYPEMAP_CONST_UNDEF) MY_STRING_2;
#endif
#if defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGUTL) #if defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGUTL)
%apply std::string& INPUT { std::string &input } %apply std::string& INPUT { std::string &input }
%apply std::string& INOUT { std::string &inout } %apply std::string& INOUT { std::string &inout }

View File

@ -1,5 +1,12 @@
%module li_std_string_extra %module li_std_string_extra
#if defined SWIGSCILAB
// Not sure what's going on here but we get:
// .././../li_std_string_extra.i:12: Warning 402: Base class 'std::string' is incomplete.
// ../../../../Lib/typemaps/std_string.swg:16: Warning 402: Only forward declaration 'std::string' was found.
%warnfilter(SWIGWARN_TYPE_INCOMPLETE) A;
#endif
%naturalvar A; %naturalvar A;

View File

@ -31,6 +31,9 @@ include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
LIBS = -L. LIBS = -L.
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
lua_no_module_global.%: SWIGOPT += -nomoduleglobal lua_no_module_global.%: SWIGOPT += -nomoduleglobal

View File

@ -84,6 +84,11 @@ include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
# Ensure testsuite remains free from SWIG warnings.
# Currently there are a lot of SWIG warnings for mzscheme, but it is marked
# as "Experimental" and slated for removal in 4.4.0 (#2830).
#SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
# none! # none!

View File

@ -58,6 +58,10 @@ run_testcase = \
include $(srcdir)/../common.mk include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options

View File

@ -34,6 +34,9 @@ include $(srcdir)/../common.mk
LIBS = -L. LIBS = -L.
CSRCS = octave_empty.c CSRCS = octave_empty.c
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
# none! # none!

View File

@ -3,8 +3,10 @@
// Tests overloading of integral and floating point types to verify the range checking required // Tests overloading of integral and floating point types to verify the range checking required
// for dispatch to the correct overloaded method // for dispatch to the correct overloaded method
#ifdef SWIGLUA #if defined SWIGGUILE || defined SWIGLUA || defined SWIGR
// Guile seems to only have one integer type and one floating point type.
// lua only has one numeric type, so most of the overloads shadow each other creating warnings // lua only has one numeric type, so most of the overloads shadow each other creating warnings
// R seems to only have one integer type.
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over; %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Nums::over;
#endif #endif

View File

@ -34,7 +34,9 @@ C_TEST_CASES += \
include $(srcdir)/../common.mk include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
# none!
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
cpp11_strongly_typed_enumerations_perl_const.cpptest: SWIGOPT += -const cpp11_strongly_typed_enumerations_perl_const.cpptest: SWIGOPT += -const

View File

@ -33,6 +33,9 @@ include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
TARGETPREFIX =# Should be php_ for Windows, empty otherwise TARGETPREFIX =# Should be php_ for Windows, empty otherwise
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
prefix.cpptest: SWIGOPT += -prefix Project prefix.cpptest: SWIGOPT += -prefix Project

View File

@ -120,6 +120,9 @@ include $(srcdir)/../common.mk
LIBS = -L. LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp VALGRIND_OPT += --suppressions=pythonswig.supp
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
python_flatstaticmethod.cpptest: SWIGOPT += -flatstaticmethod python_flatstaticmethod.cpptest: SWIGOPT += -flatstaticmethod

View File

@ -30,7 +30,9 @@ CPP_TEST_CASES += \
include $(srcdir)/../common.mk include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
# none!
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
# none! # none!

View File

@ -66,6 +66,9 @@ include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
SWIGOPT += -w801 -noautorename -features autodoc=4 SWIGOPT += -w801 -noautorename -features autodoc=4
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
ruby_alias_global_function.ctest: SWIGOPT += -globalmodule ruby_alias_global_function.ctest: SWIGOPT += -globalmodule
ruby_global_immutable_vars.ctest: SWIGOPT += -globalmodule ruby_global_immutable_vars.ctest: SWIGOPT += -globalmodule

View File

@ -35,6 +35,9 @@ include $(srcdir)/../common.mk
# Overridden variables # Overridden variables
SRCDIR = ../$(srcdir)/ SRCDIR = ../$(srcdir)/
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Local variables # Local variables
TEST_DIR = $*.dir TEST_DIR = $*.dir
RUNME_SCRIPT = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNME_SCRIPT = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)

View File

@ -26,7 +26,9 @@ C_TEST_CASES += \
include $(srcdir)/../common.mk include $(srcdir)/../common.mk
# Overridden variables here # Overridden variables here
# none!
# Ensure testsuite remains free from SWIG warnings.
SWIGOPT += -Werror
# Custom tests - tests with additional commandline options # Custom tests - tests with additional commandline options
# none! # none!

View File

@ -9,6 +9,16 @@
%rename(greater) one::DD::great; %rename(greater) one::DD::great;
%rename(greaterstill) one::DD::great(bool); %rename(greaterstill) one::DD::great(bool);
#ifdef SWIGLUA
// Lua does now have a separate integer type, but didn't used to
// and SWIG doesn't yet know about it (see #1918) so for now suppress
// warnings about functions with overloads on int vs double, etc.
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) B::get(double);
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) one::two::three::interface1::AA::great(float);
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) one::CC::great;
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) one::DD::great(float);
#endif
%inline %{ %inline %{
namespace interface1 namespace interface1
{ {