aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/errors
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/errors')
-rw-r--r--Examples/test-suite/errors/Makefile.in4
-rw-r--r--Examples/test-suite/errors/c_bad_name.i4
-rw-r--r--Examples/test-suite/errors/c_bad_name.stderr2
-rw-r--r--Examples/test-suite/errors/c_deprecated.i8
-rw-r--r--Examples/test-suite/errors/c_deprecated.stderr2
-rw-r--r--Examples/test-suite/errors/c_extra_rbrace.stderr2
-rw-r--r--Examples/test-suite/errors/c_missing_rbrace.stderr1
-rw-r--r--Examples/test-suite/errors/c_missing_semi.stderr2
-rw-r--r--Examples/test-suite/errors/c_redefine.stderr12
-rw-r--r--Examples/test-suite/errors/c_redefine_typedef.i15
-rw-r--r--Examples/test-suite/errors/c_redefine_typedef.stderr4
-rw-r--r--Examples/test-suite/errors/c_spaceship.i3
-rw-r--r--Examples/test-suite/errors/c_spaceship.stderr1
-rw-r--r--Examples/test-suite/errors/cpp_class_definition.i20
-rw-r--r--Examples/test-suite/errors/cpp_class_definition.stderr4
-rw-r--r--Examples/test-suite/errors/cpp_decltype_unsupported.i58
-rw-r--r--Examples/test-suite/errors/cpp_decltype_unsupported.stderr10
-rw-r--r--Examples/test-suite/errors/cpp_destructor_storage.i13
-rw-r--r--Examples/test-suite/errors/cpp_destructor_storage.stderr3
-rw-r--r--Examples/test-suite/errors/cpp_extend_destructors.stderr14
-rw-r--r--Examples/test-suite/errors/cpp_extend_redefine.i8
-rw-r--r--Examples/test-suite/errors/cpp_extend_redefine.stderr6
-rw-r--r--Examples/test-suite/errors/cpp_extend_redefine_template.i54
-rw-r--r--Examples/test-suite/errors/cpp_extend_redefine_template.stderr4
-rw-r--r--Examples/test-suite/errors/cpp_extra_brackets.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_invalid_template.stderr1
-rw-r--r--Examples/test-suite/errors/cpp_missing_rparenthesis.stderr1
-rw-r--r--Examples/test-suite/errors/cpp_namespace_template_bad.i18
-rw-r--r--Examples/test-suite/errors/cpp_namespace_template_bad.stderr20
-rw-r--r--Examples/test-suite/errors/cpp_namewarn.i10
-rw-r--r--Examples/test-suite/errors/cpp_namewarn.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_nested_template.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_pp_expressions_bad.i6
-rw-r--r--Examples/test-suite/errors/cpp_pp_expressions_bad.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_recursive_typedef.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_redefine_class.i38
-rw-r--r--Examples/test-suite/errors/cpp_redefine_class.stderr8
-rw-r--r--Examples/test-suite/errors/cpp_scope_bad.i37
-rw-r--r--Examples/test-suite/errors/cpp_scope_bad.stderr13
-rw-r--r--Examples/test-suite/errors/cpp_smartptr_feature.i14
-rw-r--r--Examples/test-suite/errors/cpp_smartptr_feature.stderr5
-rw-r--r--Examples/test-suite/errors/cpp_template_class_repeat.i34
-rw-r--r--Examples/test-suite/errors/cpp_template_class_repeat.stderr6
-rw-r--r--Examples/test-suite/errors/cpp_template_duplicate.i20
-rw-r--r--Examples/test-suite/errors/cpp_template_duplicate.stderr10
-rw-r--r--Examples/test-suite/errors/cpp_template_duplicate_names.stderr28
-rw-r--r--Examples/test-suite/errors/cpp_template_explicit_instantiation.i24
-rw-r--r--Examples/test-suite/errors/cpp_template_explicit_instantiation.stderr4
-rw-r--r--Examples/test-suite/errors/cpp_template_friend.stderr12
-rw-r--r--Examples/test-suite/errors/cpp_template_missing_base.i35
-rw-r--r--Examples/test-suite/errors/cpp_template_missing_base.stderr9
-rw-r--r--Examples/test-suite/errors/cpp_template_nargs.stderr4
-rw-r--r--Examples/test-suite/errors/cpp_template_partial_specialization_defaults.i9
-rw-r--r--Examples/test-suite/errors/cpp_template_partial_specialization_defaults.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_template_redefine.i107
-rw-r--r--Examples/test-suite/errors/cpp_template_redefine.stderr30
-rw-r--r--Examples/test-suite/errors/cpp_template_repeat.i13
-rw-r--r--Examples/test-suite/errors/cpp_template_repeat.stderr6
-rw-r--r--Examples/test-suite/errors/cpp_typemap_out_optimal_bug.i45
-rw-r--r--Examples/test-suite/errors/cpp_typemap_out_optimal_bug.stderr4
-rw-r--r--Examples/test-suite/errors/cpp_using_constructor_bad.i22
-rw-r--r--Examples/test-suite/errors/cpp_using_constructor_bad.stderr3
-rw-r--r--Examples/test-suite/errors/cpp_using_declaration_overload.i9
-rw-r--r--Examples/test-suite/errors/cpp_using_declaration_overload.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_using_rename.i22
-rw-r--r--Examples/test-suite/errors/cpp_using_rename.stderr7
-rw-r--r--Examples/test-suite/errors/doxygen_unclosed_tag.i6
-rw-r--r--Examples/test-suite/errors/doxygen_unclosed_tag.stderr1
-rw-r--r--Examples/test-suite/errors/pp_badeval.stderr2
-rw-r--r--Examples/test-suite/errors/pp_deprecated.stderr4
-rw-r--r--Examples/test-suite/errors/pp_error_directive.i (renamed from Examples/test-suite/errors/pp_deprecated.i)6
-rw-r--r--Examples/test-suite/errors/pp_error_directive.stderr4
-rw-r--r--Examples/test-suite/errors/pp_expressions_bad.i38
-rw-r--r--Examples/test-suite/errors/pp_expressions_bad.stderr32
-rw-r--r--Examples/test-suite/errors/pp_invalid_exponents.stderr4
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective.i5
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective.stderr2
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective4.i7
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective4.stderr1
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective5.i20
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective5.stderr1
-rw-r--r--Examples/test-suite/errors/swig_command_encoder.i6
-rw-r--r--Examples/test-suite/errors/swig_command_encoder.stderr1
-rw-r--r--Examples/test-suite/errors/swig_constant_missing_semi.i3
-rw-r--r--Examples/test-suite/errors/swig_constant_missing_semi.stderr1
-rw-r--r--Examples/test-suite/errors/swig_typemap_missing_value.i7
-rw-r--r--Examples/test-suite/errors/swig_typemap_missing_value.stderr2
-rw-r--r--Examples/test-suite/errors/swig_typemap_old.stderr4
88 files changed, 941 insertions, 118 deletions
diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in
index 7137a6862..347bf3858 100644
--- a/Examples/test-suite/errors/Makefile.in
+++ b/Examples/test-suite/errors/Makefile.in
@@ -16,6 +16,10 @@
LANGUAGE = errors
ERROR_EXT = newerr
+HAVE_CXX11 = @HAVE_CXX11@
+HAVE_CXX14 = @HAVE_CXX14@
+HAVE_CXX17 = @HAVE_CXX17@
+HAVE_CXX20 = @HAVE_CXX20@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
diff --git a/Examples/test-suite/errors/c_bad_name.i b/Examples/test-suite/errors/c_bad_name.i
deleted file mode 100644
index 43ccb4d18..000000000
--- a/Examples/test-suite/errors/c_bad_name.i
+++ /dev/null
@@ -1,4 +0,0 @@
-%module xxx
-
-%name() int foo;
-
diff --git a/Examples/test-suite/errors/c_bad_name.stderr b/Examples/test-suite/errors/c_bad_name.stderr
deleted file mode 100644
index 6c1f706a3..000000000
--- a/Examples/test-suite/errors/c_bad_name.stderr
+++ /dev/null
@@ -1,2 +0,0 @@
-c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead.
-c_bad_name.i:3: Error: Missing argument to %name directive.
diff --git a/Examples/test-suite/errors/c_deprecated.i b/Examples/test-suite/errors/c_deprecated.i
deleted file mode 100644
index 27e74397f..000000000
--- a/Examples/test-suite/errors/c_deprecated.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module xxx
-
-int foo(%val int *x, %out int *y);
-
-
-
-
-
diff --git a/Examples/test-suite/errors/c_deprecated.stderr b/Examples/test-suite/errors/c_deprecated.stderr
deleted file mode 100644
index 9e77c9ab2..000000000
--- a/Examples/test-suite/errors/c_deprecated.stderr
+++ /dev/null
@@ -1,2 +0,0 @@
-c_deprecated.i:3: Warning 102: %val directive deprecated (ignored).
-c_deprecated.i:3: Warning 103: %out directive deprecated (ignored).
diff --git a/Examples/test-suite/errors/c_extra_rbrace.stderr b/Examples/test-suite/errors/c_extra_rbrace.stderr
index 23bd41f3c..a7b19389d 100644
--- a/Examples/test-suite/errors/c_extra_rbrace.stderr
+++ b/Examples/test-suite/errors/c_extra_rbrace.stderr
@@ -1 +1 @@
-c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}'
+c_extra_rbrace.i:5: Error: Syntax error. Extraneous closing brace ('}')
diff --git a/Examples/test-suite/errors/c_missing_rbrace.stderr b/Examples/test-suite/errors/c_missing_rbrace.stderr
index 28fdd263e..7cadc0790 100644
--- a/Examples/test-suite/errors/c_missing_rbrace.stderr
+++ b/Examples/test-suite/errors/c_missing_rbrace.stderr
@@ -1,2 +1 @@
c_missing_rbrace.i:3: Error: Missing '}'. Reached end of input.
-c_missing_rbrace.i:3: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/c_missing_semi.stderr b/Examples/test-suite/errors/c_missing_semi.stderr
index 18befaa1b..9b35037ae 100644
--- a/Examples/test-suite/errors/c_missing_semi.stderr
+++ b/Examples/test-suite/errors/c_missing_semi.stderr
@@ -1 +1 @@
-c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon.
+c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon (';').
diff --git a/Examples/test-suite/errors/c_redefine.stderr b/Examples/test-suite/errors/c_redefine.stderr
index 4fccf14ea..a5996d117 100644
--- a/Examples/test-suite/errors/c_redefine.stderr
+++ b/Examples/test-suite/errors/c_redefine.stderr
@@ -1,6 +1,6 @@
-c_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored),
-c_redefine.i:3: Warning 302: previous definition of 'foo'.
-c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored),
-c_redefine.i:6: Warning 302: previous definition of 'bar'.
-c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'),
-c_redefine.i:6: Warning 322: previous declaration of 'bar'.
+c_redefine.i:4: Warning 302: Redefinition of identifier 'foo' ignored,
+c_redefine.i:3: Warning 302: previous definition of 'foo' as foo(int,int).
+c_redefine.i:8: Warning 302: Redefinition of identifier 'bar' ignored,
+c_redefine.i:6: Warning 302: previous definition of 'bar' as bar(int).
+c_redefine.i:14: Warning 322: Redundant redeclaration of identifier 'bar' (Renamed from 'spam') as spam(int) ignored,
+c_redefine.i:6: Warning 322: previous declaration of 'bar' as bar(int).
diff --git a/Examples/test-suite/errors/c_redefine_typedef.i b/Examples/test-suite/errors/c_redefine_typedef.i
new file mode 100644
index 000000000..0829eadb3
--- /dev/null
+++ b/Examples/test-suite/errors/c_redefine_typedef.i
@@ -0,0 +1,15 @@
+%module xxx
+
+
+struct Hello;
+struct Hello;
+
+struct MyStruct {
+ int x;
+};
+struct MyStruct {
+ int x;
+};
+
+typedef int Int;
+typedef int Int;
diff --git a/Examples/test-suite/errors/c_redefine_typedef.stderr b/Examples/test-suite/errors/c_redefine_typedef.stderr
new file mode 100644
index 000000000..60b63f0de
--- /dev/null
+++ b/Examples/test-suite/errors/c_redefine_typedef.stderr
@@ -0,0 +1,4 @@
+c_redefine_typedef.i:10: Warning 302: Redefinition of identifier 'MyStruct' ignored,
+c_redefine_typedef.i:7: Warning 302: previous definition of 'MyStruct'.
+c_redefine_typedef.i:15: Warning 322: Redundant redeclaration of identifier 'Int' ignored,
+c_redefine_typedef.i:14: Warning 322: previous declaration of 'Int'.
diff --git a/Examples/test-suite/errors/c_spaceship.i b/Examples/test-suite/errors/c_spaceship.i
new file mode 100644
index 000000000..da0d6c7dd
--- /dev/null
+++ b/Examples/test-suite/errors/c_spaceship.i
@@ -0,0 +1,3 @@
+%module xxx
+/* Test that the spaceship operator gives an error in C mode. */
+int a[(1<=>2>1)];
diff --git a/Examples/test-suite/errors/c_spaceship.stderr b/Examples/test-suite/errors/c_spaceship.stderr
new file mode 100644
index 000000000..bc18d45ed
--- /dev/null
+++ b/Examples/test-suite/errors/c_spaceship.stderr
@@ -0,0 +1 @@
+c_spaceship.i:3: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/cpp_class_definition.i b/Examples/test-suite/errors/cpp_class_definition.i
index 8381e75cc..d6842eef1 100644
--- a/Examples/test-suite/errors/cpp_class_definition.i
+++ b/Examples/test-suite/errors/cpp_class_definition.i
@@ -1,7 +1,7 @@
%module xxx
-// This should error but doesn't
-#if 0
+
+
namespace OtherSpace {
struct L;
}
@@ -13,7 +13,7 @@ namespace Space11 {
};
}
}
-#endif
+
namespace Space1 {
struct A;
@@ -24,3 +24,17 @@ namespace Space2 {
};
}
+namespace Space2 {
+ struct B;
+}
+
+struct ::Space2::B {
+ int val;
+ B() : val() {}
+};
+
+struct XX;
+// g++: error: global qualification of class name is invalid before ‘{’ token
+struct ::XX {
+ int vvv;
+};
diff --git a/Examples/test-suite/errors/cpp_class_definition.stderr b/Examples/test-suite/errors/cpp_class_definition.stderr
index 2c4102842..744ae70af 100644
--- a/Examples/test-suite/errors/cpp_class_definition.stderr
+++ b/Examples/test-suite/errors/cpp_class_definition.stderr
@@ -1 +1,5 @@
+cpp_class_definition.i:11: Warning 302: Redefinition of identifier 'L' as Space11::SubSpace11::L ignored,
+cpp_class_definition.i:10: Warning 302: previous definition of 'L' as Space11::SubSpace11::L.
cpp_class_definition.i:22: Error: 'Space1::A' resolves to 'Space1::A' and was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
+cpp_class_definition.i:31: Error: Using the unary scope operator :: in class definition '::Space2::B' is invalid.
+cpp_class_definition.i:38: Error: Using the unary scope operator :: in class definition '::XX' is invalid.
diff --git a/Examples/test-suite/errors/cpp_decltype_unsupported.i b/Examples/test-suite/errors/cpp_decltype_unsupported.i
new file mode 100644
index 000000000..9b01f5649
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_decltype_unsupported.i
@@ -0,0 +1,58 @@
+#ifdef SWIG
+%module xxx
+#endif
+
+// Test that decltype cases where SWIG doesn't yet support deducing the type
+// are handled gracefully.
+//
+// To check testcases are valid C++:
+// g++ -std=c++20 -Wall -W -xc++ -c cpp_decltype_unsupported.i
+
+// Function return type
+static int func_returning_int(int x = 0) { return x; }
+static int global_int = 42;
+decltype(func_returning_int()) func_return;
+decltype(func_returning_int(0)) func_return2;
+
+// Address of (other than char or wchar_t)
+decltype(&global_int) address_of;
+
+// Pointer dereference (other than of char* or wchar_t*).
+#ifdef SWIG
+%ignore pointer_to_int;
+#endif
+int* pointer_to_int;
+decltype(*pointer_to_int) pointer_dereference = *pointer_to_int;
+
+// Variable SWIG doesn't know about.
+#ifndef SWIG
+static int undeclared_variable = 1;
+#endif
+decltype(undeclared_variable) unknown_to_swig;
+
+// Constructed object.
+struct A {};
+decltype(A()) constructed_object;
+
+// Spaceship operator.
+#include <compare>
+decltype(1 <=> 2) spaceship = (1 <=> 2);
+
+// Array dereference.
+decltype(("abc"[1])) array_deref = 0;
+constexpr auto array_deref2{"abc"[1]};
+// FIXME: SWIG fails to parse these cases:
+#ifndef SWIG
+decltype("abc"[1]) array_deref3 = 0;
+constexpr auto array_deref4 = ("abc"[1]);
+constexpr auto array_deref5("abc"[1]);
+#endif
+
+// Comparisons.
+// FIXME SWIG fails to parse both these with `Error: Missing ')'. Reached end of input.`
+//decltype(1 < 2) lt_test = 0;
+//decltype(1 > 2) gt_test = 0;
+
+// Assignment.
+bool a;
+decltype((a = true) + 1) assignment = true;
diff --git a/Examples/test-suite/errors/cpp_decltype_unsupported.stderr b/Examples/test-suite/errors/cpp_decltype_unsupported.stderr
new file mode 100644
index 000000000..d688d25a4
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_decltype_unsupported.stderr
@@ -0,0 +1,10 @@
+cpp_decltype_unsupported.i:14: Warning 344: Unable to deduce decltype for 'func_returning_int()'.
+cpp_decltype_unsupported.i:15: Warning 344: Unable to deduce decltype for 'func_returning_int(0)'.
+cpp_decltype_unsupported.i:18: Warning 344: Unable to deduce decltype for '&global_int'.
+cpp_decltype_unsupported.i:25: Warning 344: Unable to deduce decltype for '*pointer_to_int'.
+cpp_decltype_unsupported.i:31: Warning 344: Unable to deduce decltype for 'undeclared_variable'.
+cpp_decltype_unsupported.i:35: Warning 344: Unable to deduce decltype for 'A()'.
+cpp_decltype_unsupported.i:39: Warning 344: Unable to deduce decltype for '1 <=> 2'.
+cpp_decltype_unsupported.i:42: Warning 344: Unable to deduce decltype for '("abc"[1])'.
+cpp_decltype_unsupported.i:43: Warning 346: Unable to deduce auto type for variable 'array_deref2' (ignored).
+cpp_decltype_unsupported.i:58: Warning 344: Unable to deduce decltype for '(a = true) + 1'.
diff --git a/Examples/test-suite/errors/cpp_destructor_storage.i b/Examples/test-suite/errors/cpp_destructor_storage.i
new file mode 100644
index 000000000..985f3b68c
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_destructor_storage.i
@@ -0,0 +1,13 @@
+%module xxx
+
+struct BadDestructor1 {
+ virtual ~BadDestructor1() = 1;
+};
+
+struct BadDestructor2 {
+ ~BadDestructor2() = 0;
+};
+
+struct BadDestructor3 {
+ ~BadDestructor3() const;
+};
diff --git a/Examples/test-suite/errors/cpp_destructor_storage.stderr b/Examples/test-suite/errors/cpp_destructor_storage.stderr
new file mode 100644
index 000000000..642a345df
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_destructor_storage.stderr
@@ -0,0 +1,3 @@
+cpp_destructor_storage.i:4: Error: Destructor ~BadDestructor1() has an invalid pure specifier, only = 0 is allowed.
+cpp_destructor_storage.i:8: Error: Destructor ~BadDestructor2() uses a pure specifier but is not virtual.
+cpp_destructor_storage.i:12: Error: Destructor ~BadDestructor3() const cannot have a qualifier.
diff --git a/Examples/test-suite/errors/cpp_extend_destructors.stderr b/Examples/test-suite/errors/cpp_extend_destructors.stderr
index 1eef277dc..b5de8cc34 100644
--- a/Examples/test-suite/errors/cpp_extend_destructors.stderr
+++ b/Examples/test-suite/errors/cpp_extend_destructors.stderr
@@ -1,11 +1,11 @@
-cpp_extend_destructors.i:8: Warning 302: Identifier '~AStruct' redefined by %extend (ignored),
+cpp_extend_destructors.i:8: Warning 302: Redefinition of identifier '~AStruct' by %extend ignored,
cpp_extend_destructors.i:5: Warning 302: %extend definition of '~AStruct'.
-cpp_extend_destructors.i:14: Warning 302: Identifier '~BStruct' redefined (ignored),
-cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct'.
-cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignored),
-cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct'.
-cpp_extend_destructors.i:100: Warning 302: Identifier '~LStruct' redefined (ignored),
-cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct'.
+cpp_extend_destructors.i:14: Warning 302: Redefinition of identifier '~BStruct' as BStruct::~BStruct() ignored,
+cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct' as BStruct::~BStruct().
+cpp_extend_destructors.i:87: Warning 302: Redefinition of identifier '~JStruct' as JStruct::~JStruct() ignored,
+cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct' as JStruct::~JStruct().
+cpp_extend_destructors.i:100: Warning 302: Redefinition of identifier '~LStruct' as LStruct::~LStruct() ignored,
+cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct' as LStruct::~LStruct().
cpp_extend_destructors.i:24: Warning 521: Illegal destructor name CStruct::~NOT_CStruct(). Ignored.
cpp_extend_destructors.i:30: Warning 521: Illegal destructor name DStruct::~NOT_DStruct(). Ignored.
cpp_extend_destructors.i:44: Warning 521: Illegal destructor name EStruct::~NOT_EStruct(). Ignored.
diff --git a/Examples/test-suite/errors/cpp_extend_redefine.i b/Examples/test-suite/errors/cpp_extend_redefine.i
index dfe8fe48a..f13d49779 100644
--- a/Examples/test-suite/errors/cpp_extend_redefine.i
+++ b/Examples/test-suite/errors/cpp_extend_redefine.i
@@ -13,11 +13,3 @@ struct foo {
%extend foo {
int spam();
};
-
-
-
-
-
-
-
-
diff --git a/Examples/test-suite/errors/cpp_extend_redefine.stderr b/Examples/test-suite/errors/cpp_extend_redefine.stderr
index 94770f5d7..2e46a33c8 100644
--- a/Examples/test-suite/errors/cpp_extend_redefine.stderr
+++ b/Examples/test-suite/errors/cpp_extend_redefine.stderr
@@ -1,4 +1,4 @@
-cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
+cpp_extend_redefine.i:9: Warning 302: Redefinition of identifier 'bar' by %extend ignored,
cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
-cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam',
-cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'.
+cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of identifier 'spam' as foo::spam() ignored,
+cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam' as foo::spam().
diff --git a/Examples/test-suite/errors/cpp_extend_redefine_template.i b/Examples/test-suite/errors/cpp_extend_redefine_template.i
new file mode 100644
index 000000000..edc6d7cc3
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_extend_redefine_template.i
@@ -0,0 +1,54 @@
+%module xxx
+
+%extend FooT<int> {
+ FooT(int a) { return new FooT<T>(); }
+ ~FooT() { delete $self;}
+ int spam(const char *) { return x; }
+ int spam(int x) { return x; }
+ int spam(int x, int y) { return x + y ; }
+ int spam(int x, int y,int z) { return x + y ; }
+ int spam(Foo f, double d = 10.0) { return 0; }
+};
+
+%inline %{
+template<class T>
+class FooT {
+public:
+ FooT(){}
+
+#ifdef SWIG
+%extend { FooT(int a, int b) { return new FooT<T>(); } }
+#endif
+
+ int spam() { return 1; }
+ int spam(const char* c) { return 2; }
+};
+%}
+
+%template(FooTi) FooT<int>;
+
+
+// After the class
+
+%inline %{
+template<class T>
+class BarT {
+public:
+ BarT() { }
+ int spam() { return 1; }
+ int spam(const char* c) { return 2; }
+};
+%}
+
+
+%extend BarT<int> {
+ BarT(int a) { return new BarT<T>(); }
+ ~BarT() { delete $self;}
+ int spam(const char *) { return 1}
+ int spam(int x) { return x; }
+ int spam(int x, int y) { return x + y ; }
+ int spam(int x, int y,int z) { return x + y ; }
+ int spam(Bar b, double d = 10.0) { return 0; }
+};
+
+%template(BarTi) BarT<int>;
diff --git a/Examples/test-suite/errors/cpp_extend_redefine_template.stderr b/Examples/test-suite/errors/cpp_extend_redefine_template.stderr
new file mode 100644
index 000000000..88454c4ce
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_extend_redefine_template.stderr
@@ -0,0 +1,4 @@
+cpp_extend_redefine_template.i:24: Warning 302: Redefinition of identifier 'spam' by %extend ignored,
+cpp_extend_redefine_template.i:6: Warning 302: %extend definition of 'spam'.
+cpp_extend_redefine_template.i:39: Warning 302: Redefinition of identifier 'spam' by %extend ignored,
+cpp_extend_redefine_template.i:47: Warning 302: %extend definition of 'spam'.
diff --git a/Examples/test-suite/errors/cpp_extra_brackets.stderr b/Examples/test-suite/errors/cpp_extra_brackets.stderr
index f1fabc78d..901bed6a9 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets.stderr
+++ b/Examples/test-suite/errors/cpp_extra_brackets.stderr
@@ -1 +1 @@
-cpp_extra_brackets.i:5: Error: Unexpected ')'.
+cpp_extra_brackets.i:5: Error: Unexpected closing parenthesis (')').
diff --git a/Examples/test-suite/errors/cpp_invalid_template.stderr b/Examples/test-suite/errors/cpp_invalid_template.stderr
index f6bfaaf7d..f39464942 100644
--- a/Examples/test-suite/errors/cpp_invalid_template.stderr
+++ b/Examples/test-suite/errors/cpp_invalid_template.stderr
@@ -1,3 +1,2 @@
-cpp_invalid_template.i:3: Error: Undefined scope 'SSS'
cpp_invalid_template.i:3: Error: Template 'SSS::AAA' undefined.
cpp_invalid_template.i:9: Error: 'JJJ' is not defined as a template. (classforward)
diff --git a/Examples/test-suite/errors/cpp_missing_rparenthesis.stderr b/Examples/test-suite/errors/cpp_missing_rparenthesis.stderr
index cc97f5c68..5b826aa14 100644
--- a/Examples/test-suite/errors/cpp_missing_rparenthesis.stderr
+++ b/Examples/test-suite/errors/cpp_missing_rparenthesis.stderr
@@ -1,2 +1 @@
cpp_missing_rparenthesis.i:5: Error: Missing ')'. Reached end of input.
-cpp_missing_rparenthesis.i:5: Error: Syntax error in input(3).
diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.i b/Examples/test-suite/errors/cpp_namespace_template_bad.i
index f41918f8e..d8a33098e 100644
--- a/Examples/test-suite/errors/cpp_namespace_template_bad.i
+++ b/Examples/test-suite/errors/cpp_namespace_template_bad.i
@@ -9,6 +9,11 @@ namespace test {
};
}
+namespace test1 {
+ %template(maxchar) ::test::max<char>;
+ %template(vectorchar) ::test::vector<char>;
+}
+
namespace test2 {
using namespace test;
%template(maxshort) max<short>;
@@ -32,9 +37,18 @@ namespace test4 {
%template(vectorInteger) vector<Integer>;
}
-using namespace test;
namespace test5 {
+// Empty namespace
+}
+template<typename T> struct GlobalVector {
+ void gook(T i) {}
+ void geeko(double d) {}
+ void geeky(int d) {}
+};
+%template(GlobalVectorIntPtr) test5::GlobalVector<int *>; // should fail as GlobalVector is in global namespace
+
+using namespace test;
+namespace test6 {
%template(maxdouble) max<double>;
%template(vectordouble) vector<double>;
}
-
diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.stderr b/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
index 5965d529c..d6ee15d5f 100644
--- a/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
+++ b/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
@@ -1,9 +1,11 @@
-cpp_namespace_template_bad.i:14: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
-cpp_namespace_template_bad.i:15: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
-cpp_namespace_template_bad.i:21: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
-cpp_namespace_template_bad.i:22: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
-cpp_namespace_template_bad.i:31: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
-cpp_namespace_template_bad.i:32: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
-cpp_namespace_template_bad.i:37: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
-cpp_namespace_template_bad.i:37: Error: Template 'max' undefined.
-cpp_namespace_template_bad.i:38: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
+cpp_namespace_template_bad.i:13: Error: '::test::max' resolves to 'test::max' and was incorrectly instantiated in scope 'test1' instead of within scope 'test'.
+cpp_namespace_template_bad.i:14: Error: '::test::vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test1' instead of within scope 'test'.
+cpp_namespace_template_bad.i:19: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
+cpp_namespace_template_bad.i:20: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
+cpp_namespace_template_bad.i:26: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
+cpp_namespace_template_bad.i:27: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
+cpp_namespace_template_bad.i:36: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
+cpp_namespace_template_bad.i:37: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
+cpp_namespace_template_bad.i:48: Error: Template 'test5::GlobalVector' undefined.
+cpp_namespace_template_bad.i:52: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test6' instead of within scope 'test'.
+cpp_namespace_template_bad.i:53: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test6' instead of within scope 'test'.
diff --git a/Examples/test-suite/errors/cpp_namewarn.i b/Examples/test-suite/errors/cpp_namewarn.i
index c0edc4b4e..5c62cebeb 100644
--- a/Examples/test-suite/errors/cpp_namewarn.i
+++ b/Examples/test-suite/errors/cpp_namewarn.i
@@ -1,10 +1,10 @@
%module xxx
-%namewarn("314:'key1' is a keyword, renaming to '_key1'", rename="_%s") "key1";
-%namewarn("314:'key2' is a keyword, renaming to '_key2'", rename="_%s") "key2";
-%namewarn("314:'key3' is a keyword, renaming to '_key3'", rename="_%s") "key3";
-%namewarn("314:'key4' is a keyword, renaming to '_key4'", rename="_%s") "key4";
-%namewarn("314:'key5' is a keyword, renaming to '_key5'", rename="_%s") "key5";
+%namewarn("314:'key1' is a keyword", rename="_%s") "key1";
+%namewarn("314:'key2' is a keyword", rename="_%s") "key2";
+%namewarn("314:'key3' is a keyword", rename="_%s") "key3";
+%namewarn("314:'key4' is a keyword", rename="_%s") "key4";
+%namewarn("314:'key5' is a keyword", rename="_%s") "key5";
// Non-templated
%ignore KlassA::key1;
diff --git a/Examples/test-suite/errors/cpp_namewarn.stderr b/Examples/test-suite/errors/cpp_namewarn.stderr
index e5b893268..7cc640e28 100644
--- a/Examples/test-suite/errors/cpp_namewarn.stderr
+++ b/Examples/test-suite/errors/cpp_namewarn.stderr
@@ -7,4 +7,4 @@ cpp_namewarn.i:67: Warning 314: 'key3' is a keyword, renaming to '_key3'
cpp_namewarn.i:72: Warning 314: 'key1' is a keyword, renaming to '_key1'
cpp_namewarn.i:73: Warning 314: 'key2' is a keyword, renaming to '_key2'
cpp_namewarn.i:74: Warning 314: 'key3' is a keyword, renaming to '_key3'
-cpp_namewarn.i:80: Warning 314: 'key5' is a keyword, renaming to '_key5'
+cpp_namewarn.i:80: Warning 314: 'key5' is a keyword
diff --git a/Examples/test-suite/errors/cpp_nested_template.stderr b/Examples/test-suite/errors/cpp_nested_template.stderr
index 363a260f6..5b107cad4 100644
--- a/Examples/test-suite/errors/cpp_nested_template.stderr
+++ b/Examples/test-suite/errors/cpp_nested_template.stderr
@@ -1,4 +1,2 @@
cpp_nested_template.i:9: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'A' instead of within scope ''.
-cpp_nested_template.i:9: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
cpp_nested_template.i:18: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'B' instead of within scope ''.
-cpp_nested_template.i:18: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
diff --git a/Examples/test-suite/errors/cpp_pp_expressions_bad.i b/Examples/test-suite/errors/cpp_pp_expressions_bad.i
new file mode 100644
index 000000000..2f71232fe
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_pp_expressions_bad.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+/* Spaceship operator doesn't seem to be allowed in preprocessor expressions. */
+#if (4 <=> 2) < 0
+#endif
diff --git a/Examples/test-suite/errors/cpp_pp_expressions_bad.stderr b/Examples/test-suite/errors/cpp_pp_expressions_bad.stderr
new file mode 100644
index 000000000..d95d416f5
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_pp_expressions_bad.stderr
@@ -0,0 +1,2 @@
+cpp_pp_expressions_bad.i:5: Warning 202: Could not evaluate expression '(4 <=> 2) < 0'
+cpp_pp_expressions_bad.i:5: Warning 202: Spaceship operator (<=>) not allowed in preprocessor expression
diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.stderr b/Examples/test-suite/errors/cpp_recursive_typedef.stderr
index d9135aa43..b5a59238b 100644
--- a/Examples/test-suite/errors/cpp_recursive_typedef.stderr
+++ b/Examples/test-suite/errors/cpp_recursive_typedef.stderr
@@ -1 +1 @@
-:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
+cpp_recursive_typedef.i:3: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
diff --git a/Examples/test-suite/errors/cpp_redefine_class.i b/Examples/test-suite/errors/cpp_redefine_class.i
new file mode 100644
index 000000000..ffffc154b
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_redefine_class.i
@@ -0,0 +1,38 @@
+%module xxx
+
+namespace Space {
+struct MyStruct {
+ int b;
+};
+}
+
+namespace Space {
+struct MyStruct {
+ int b;
+};
+}
+
+namespace Space {
+class MyClass {
+public:
+ int a;
+};
+}
+
+class Space::MyClass {
+public:
+ int a;
+};
+
+namespace Space {
+template<typename T>
+class MyTemplateClass {
+public:
+ int a;
+};
+template<typename T>
+class MyTemplateClass {
+public:
+ int a;
+};
+}
diff --git a/Examples/test-suite/errors/cpp_redefine_class.stderr b/Examples/test-suite/errors/cpp_redefine_class.stderr
new file mode 100644
index 000000000..95d2ff7ef
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_redefine_class.stderr
@@ -0,0 +1,8 @@
+cpp_redefine_class.i:10: Warning 302: Redefinition of identifier 'MyStruct' as Space::MyStruct ignored,
+cpp_redefine_class.i:4: Warning 302: previous definition of 'MyStruct' as Space::MyStruct.
+cpp_redefine_class.i:22: Warning 302: Redefinition of identifier 'MyClass' as Space::MyClass ignored,
+cpp_redefine_class.i:16: Warning 302: previous definition of 'MyClass' as Space::MyClass.
+cpp_redefine_class.i:34: Warning 302: Redefinition of identifier 'MyTemplateClass' as Space::MyTemplateClass ignored,
+cpp_redefine_class.i:29: Warning 302: previous definition of 'MyTemplateClass' as Space::MyTemplateClass.
+cpp_redefine_class.i:34: Warning 302: Redefinition of identifier 'MyTemplateClass' as Space::MyTemplateClass ignored,
+cpp_redefine_class.i:29: Warning 302: previous definition of 'MyTemplateClass' as Space::MyTemplateClass.
diff --git a/Examples/test-suite/errors/cpp_scope_bad.i b/Examples/test-suite/errors/cpp_scope_bad.i
new file mode 100644
index 000000000..0396c40fc
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_scope_bad.i
@@ -0,0 +1,37 @@
+%module xxx
+
+template <typename Tnum>
+class Space::A<Tnum>::Anest {
+public:
+ Anest();
+};
+
+namespace N {
+ template<typename T> class C {};
+}
+namespace unrelated {
+ %template(cin) N::C<int>;
+ template class N::C<int>;
+}
+struct Outer {
+ struct Unrelated<X> {
+ %template(cin) N::C<int>;
+ template class N::C<int>;
+ };
+};
+
+struct ::X::Y<int> {
+};
+
+using namespace Nope<double>;
+
+template<typename T>
+struct NotANamespace {
+};
+%template(NotANamespaceInt) NotANamespace<int>;
+%template() NotANamespace<double>;
+
+using namespace NotANamespace<double>;
+
+namespace BadEquivalent = NotANamespace<int>;
+namespace AwfulEquivalent = Nope<double>;
diff --git a/Examples/test-suite/errors/cpp_scope_bad.stderr b/Examples/test-suite/errors/cpp_scope_bad.stderr
new file mode 100644
index 000000000..d2387febd
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_scope_bad.stderr
@@ -0,0 +1,13 @@
+cpp_scope_bad.i:4: Error: Undefined scope 'Space::A< Tnum >'
+cpp_scope_bad.i:4: Warning 317: Specialization of non-template 'Space::A'.
+cpp_scope_bad.i:13: Error: 'N::C' resolves to 'N::C' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'N'.
+cpp_scope_bad.i:14: Warning 320: Explicit template instantiation ignored.
+cpp_scope_bad.i:18: Error: 'N::C' resolves to 'N::C' and was incorrectly instantiated in scope 'Outer::Unrelated< X >' instead of within scope 'N'.
+cpp_scope_bad.i:19: Warning 320: Explicit template instantiation ignored.
+cpp_scope_bad.i:20: Warning 325: Nested struct not currently supported (Unrelated< X > ignored)
+cpp_scope_bad.i:23: Error: Using the unary scope operator :: in class definition '::X::Y< int >' is invalid.
+cpp_scope_bad.i:26: Error: Nothing known about namespace 'Nope< double >'
+cpp_scope_bad.i:34: Error: 'NotANamespace< double >' is not a namespace.
+cpp_scope_bad.i:36: Error: 'NotANamespace< int >' is not a namespace
+cpp_scope_bad.i:37: Error: Unknown namespace 'Nope< double >'
+cpp_scope_bad.i:23: Warning 503: Can't wrap class Y< int > unless renamed to a valid identifier.
diff --git a/Examples/test-suite/errors/cpp_smartptr_feature.i b/Examples/test-suite/errors/cpp_smartptr_feature.i
new file mode 100644
index 000000000..4a0d510cd
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_smartptr_feature.i
@@ -0,0 +1,14 @@
+%module xxx
+
+%feature("smartptr", noblock=1) AA { std::shared_ptr< AA > }
+%feature("smartptr", noblock=1) DD { std::shared_ptr< }
+
+
+struct AA {};
+struct BB : AA {};
+struct CC : AA {};
+struct DD : AA {};
+
+%feature("smartptr", noblock=1) YY { std::shared_ptr< YY > }
+struct XX {};
+struct YY : XX {};
diff --git a/Examples/test-suite/errors/cpp_smartptr_feature.stderr b/Examples/test-suite/errors/cpp_smartptr_feature.stderr
new file mode 100644
index 000000000..442f795ac
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_smartptr_feature.stderr
@@ -0,0 +1,5 @@
+cpp_smartptr_feature.i:8: Warning 520: Derived class 'BB' of 'AA' is not similarly marked as a smart pointer.
+cpp_smartptr_feature.i:9: Warning 520: Derived class 'CC' of 'AA' is not similarly marked as a smart pointer.
+cpp_smartptr_feature.i:10: Error: Invalid type (std::shared_ptr<) in 'smartptr' feature for class DD.
+cpp_smartptr_feature.i:10: Warning 520: Derived class 'DD' of 'AA' is not similarly marked as a smart pointer.
+cpp_smartptr_feature.i:14: Warning 520: Base class 'XX' of 'YY' is not similarly marked as a smart pointer.
diff --git a/Examples/test-suite/errors/cpp_template_class_repeat.i b/Examples/test-suite/errors/cpp_template_class_repeat.i
new file mode 100644
index 000000000..c8bffd47a
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_class_repeat.i
@@ -0,0 +1,34 @@
+%module xxx
+
+template<typename T> struct A {};
+%template(Aint) A<int>;
+%template(Aint2) A<int>; // Now ignored and issues a warning
+
+template<typename T> struct B {};
+%template() B<int>;
+%template(Bint) B<int>; // OK
+
+template<typename T> struct C {};
+%template() C<int>;
+%template() C<int>; // Quietly ignored now
+%template(Cint) C<int>; // OK
+
+template <typename T, typename U = short> struct D {};
+%template(Dint) D<int>;
+%template(Dintshort) D<int, short>;
+
+template<typename T> struct E {};
+%template(Eint) E<int>;
+%template(Eint) E<int>; // Always has been ignored as a redefined identifier
+
+
+template<typename T> struct F {};
+%template(Fint) F<int>;
+%template() F<int>; // Quietly ignored
+%template() F<int>; // Quietly ignored
+
+template<typename T> struct G {};
+%template() G<int>;
+%template() G<int>; // Quietly ignored
+%template(Gint) G<int>;
+%template() G<int>; // Quietly ignored
diff --git a/Examples/test-suite/errors/cpp_template_class_repeat.stderr b/Examples/test-suite/errors/cpp_template_class_repeat.stderr
new file mode 100644
index 000000000..db283dc26
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_class_repeat.stderr
@@ -0,0 +1,6 @@
+cpp_template_class_repeat.i:5: Warning 404: Duplicate template instantiation of 'A< int >' with name 'Aint2' ignored,
+cpp_template_class_repeat.i:4: Warning 404: previous instantiation of 'A< int >' with name 'Aint'.
+cpp_template_class_repeat.i:18: Warning 404: Duplicate template instantiation of 'D< int,short >' with name 'Dintshort' ignored,
+cpp_template_class_repeat.i:17: Warning 404: previous instantiation of 'D< int >' with name 'Dint'.
+cpp_template_class_repeat.i:22: Warning 404: Duplicate template instantiation of 'E< int >' with name 'Eint' ignored,
+cpp_template_class_repeat.i:21: Warning 404: previous instantiation of 'E< int >' with name 'Eint'.
diff --git a/Examples/test-suite/errors/cpp_template_duplicate.i b/Examples/test-suite/errors/cpp_template_duplicate.i
new file mode 100644
index 000000000..672c9884f
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_duplicate.i
@@ -0,0 +1,20 @@
+%module xxx
+
+%include <std_vector.i>
+
+// Note these 404 warnings come from two different places in the SWIG code base
+
+%inline %{
+typedef unsigned char uint8_T;
+typedef unsigned char boolean_T;
+%}
+
+%template(std_vector_boolean_type) std::vector<boolean_T>;
+%template(std_vector_boolean_type_duplicate) std::vector<boolean_T>;
+%template(std_vector_uint8_type) std::vector<uint8_T>;
+
+namespace std {
+%template(std_vector_boolean_type_again) vector<boolean_T>;
+%template(std_vector_uint8_type_again) vector<uint8_T>;
+%template(std_vector_unsigned_char) vector<unsigned char>;
+}
diff --git a/Examples/test-suite/errors/cpp_template_duplicate.stderr b/Examples/test-suite/errors/cpp_template_duplicate.stderr
new file mode 100644
index 000000000..b23e64dbb
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_duplicate.stderr
@@ -0,0 +1,10 @@
+cpp_template_duplicate.i:13: Warning 404: Duplicate template instantiation of 'vector< boolean_T >' with name 'std_vector_boolean_type_duplicate' ignored,
+cpp_template_duplicate.i:12: Warning 404: previous instantiation of 'vector< boolean_T >' with name 'std_vector_boolean_type'.
+cpp_template_duplicate.i:17: Warning 404: Duplicate template instantiation of 'vector< boolean_T >' with name 'std_vector_boolean_type_again' ignored,
+cpp_template_duplicate.i:12: Warning 404: previous instantiation of 'vector< boolean_T >' with name 'std_vector_boolean_type'.
+cpp_template_duplicate.i:18: Warning 404: Duplicate template instantiation of 'vector< uint8_T >' with name 'std_vector_uint8_type_again' ignored,
+cpp_template_duplicate.i:14: Warning 404: previous instantiation of 'vector< uint8_T >' with name 'std_vector_uint8_type'.
+cpp_template_duplicate.i:12: Warning 404: Duplicate template instantiation of 'vector< boolean_T >' with name 'std_vector_boolean_type' ignored,
+cpp_template_duplicate.i:19: Warning 404: previous instantiation of 'vector< unsigned char >' with name 'std_vector_unsigned_char'.
+cpp_template_duplicate.i:14: Warning 404: Duplicate template instantiation of 'vector< uint8_T >' with name 'std_vector_uint8_type' ignored,
+cpp_template_duplicate.i:19: Warning 404: previous instantiation of 'vector< unsigned char >' with name 'std_vector_unsigned_char'.
diff --git a/Examples/test-suite/errors/cpp_template_duplicate_names.stderr b/Examples/test-suite/errors/cpp_template_duplicate_names.stderr
index 9856ff563..f1acbc29e 100644
--- a/Examples/test-suite/errors/cpp_template_duplicate_names.stderr
+++ b/Examples/test-suite/errors/cpp_template_duplicate_names.stderr
@@ -1,14 +1,14 @@
-cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
-cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
-cpp_template_duplicate_names.i:14: Warning 302: Identifier 'Duplicate1' redefined (ignored),
-cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1'.
-cpp_template_duplicate_names.i:25: Warning 302: Identifier 'Duplicate2_0' redefined (ignored) (Renamed from 'Duplicate2< 0 >'),
-cpp_template_duplicate_names.i:24: Warning 302: previous definition of 'Duplicate2_0' (Renamed from 'Duplicate2< 0 >').
-cpp_template_duplicate_names.i:35: Warning 302: Identifier 'Duplicate3' redefined (ignored) (Renamed from 'Duplicate3< 0 >'),
-cpp_template_duplicate_names.i:31: Warning 302: previous definition of 'Duplicate3'.
-cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
-cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
-cpp_template_duplicate_names.i:47: Warning 302: Identifier 'Duplicate4' redefined (ignored),
-cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
-cpp_template_duplicate_names.i:50: Warning 302: Identifier 'Duplicate4' redefined (ignored) (Renamed from 'Duplicate4< 0 >'),
-cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4'.
+cpp_template_duplicate_names.i:14: Warning 302: Redefinition of identifier 'Duplicate1' as Space::Duplicate1 ignored,
+cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1' as Space::Duplicate1.
+cpp_template_duplicate_names.i:14: Warning 302: Redefinition of identifier 'Duplicate1' as Space::Duplicate1 ignored,
+cpp_template_duplicate_names.i:13: Warning 302: previous definition of 'Duplicate1' as Space::Duplicate1.
+cpp_template_duplicate_names.i:25: Warning 404: Duplicate template instantiation of 'Duplicate2< 0 >' with name 'Duplicate2_0' ignored,
+cpp_template_duplicate_names.i:24: Warning 404: previous instantiation of 'Duplicate2< 0 >' with name 'Duplicate2_0'.
+cpp_template_duplicate_names.i:35: Warning 404: Duplicate template instantiation of 'Duplicate3< 0 >' with name 'Duplicate3' ignored,
+cpp_template_duplicate_names.i:34: Warning 404: previous instantiation of 'Duplicate3< 0 >' with name 'Duplicate3'.
+cpp_template_duplicate_names.i:47: Warning 302: Redefinition of identifier 'Duplicate4' as Space::Duplicate4 ignored,
+cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4' as Space::Duplicate4.
+cpp_template_duplicate_names.i:47: Warning 302: Redefinition of identifier 'Duplicate4' as Space::Duplicate4 ignored,
+cpp_template_duplicate_names.i:46: Warning 302: previous definition of 'Duplicate4' as Space::Duplicate4.
+cpp_template_duplicate_names.i:50: Warning 404: Duplicate template instantiation of 'Duplicate4< 0 >' with name 'Duplicate4' ignored,
+cpp_template_duplicate_names.i:49: Warning 404: previous instantiation of 'Duplicate4< 0 >' with name 'Duplicate4'.
diff --git a/Examples/test-suite/errors/cpp_template_explicit_instantiation.i b/Examples/test-suite/errors/cpp_template_explicit_instantiation.i
new file mode 100644
index 000000000..97513724b
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_explicit_instantiation.i
@@ -0,0 +1,24 @@
+%module xxx
+
+%inline %{
+namespace std {
+ template<typename T> class vector {};
+}
+template<typename T> void Func() {}
+%}
+
+%inline %{
+// Class template
+template class std::vector<int>; // C++03 template explicit instantiation definition in C++
+extern template class std::vector<int>; // C++11 template explicit instantiation declaration (extern template)
+%}
+%template(VectorInt) std::vector<int>; // SWIG template instantiation
+
+%inline %{
+// Function template
+template void Func<int>(); // C++03 template explicit instantiation definition in C++
+extern template void Func<int>(); // C++11 template explicit instantiation declaration (extern template)
+%}
+%template(FuncInt) Func<int>; // SWIG template instantiation
+
+
diff --git a/Examples/test-suite/errors/cpp_template_explicit_instantiation.stderr b/Examples/test-suite/errors/cpp_template_explicit_instantiation.stderr
new file mode 100644
index 000000000..052d3de27
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_explicit_instantiation.stderr
@@ -0,0 +1,4 @@
+cpp_template_explicit_instantiation.i:12: Warning 320: Explicit template instantiation ignored.
+cpp_template_explicit_instantiation.i:13: Warning 327: Extern template ignored.
+cpp_template_explicit_instantiation.i:19: Warning 320: Explicit template instantiation ignored.
+cpp_template_explicit_instantiation.i:20: Warning 327: Extern template ignored.
diff --git a/Examples/test-suite/errors/cpp_template_friend.stderr b/Examples/test-suite/errors/cpp_template_friend.stderr
index 8dea195dc..04ecc8648 100644
--- a/Examples/test-suite/errors/cpp_template_friend.stderr
+++ b/Examples/test-suite/errors/cpp_template_friend.stderr
@@ -1,8 +1,8 @@
-cpp_template_friend.i:4: Warning 302: Identifier 'template_friend1' redefined (ignored),
+cpp_template_friend.i:4: Warning 302: Redefinition of identifier 'template_friend1' ignored,
cpp_template_friend.i:3: Warning 302: previous definition of 'template_friend1'.
-cpp_template_friend.i:13: Warning 302: Identifier 'template_friend2' redefined (ignored),
+cpp_template_friend.i:13: Warning 302: Redefinition of identifier 'template_friend2' ignored,
cpp_template_friend.i:9: Warning 302: previous definition of 'template_friend2'.
-cpp_template_friend.i:17: Warning 322: Redundant redeclaration of 'normal_friend1',
-cpp_template_friend.i:16: Warning 322: previous declaration of 'normal_friend1'.
-cpp_template_friend.i:26: Warning 322: Redundant redeclaration of 'normal_friend2',
-cpp_template_friend.i:22: Warning 322: previous declaration of 'normal_friend2'.
+cpp_template_friend.i:17: Warning 322: Redundant redeclaration of identifier 'normal_friend1' as normal_friend1(int) ignored,
+cpp_template_friend.i:16: Warning 322: previous declaration of 'normal_friend1' as normal_friend1(int).
+cpp_template_friend.i:26: Warning 322: Redundant redeclaration of identifier 'normal_friend2' as normal_friend2(int) ignored,
+cpp_template_friend.i:22: Warning 322: previous declaration of 'normal_friend2' as normal_friend2(int).
diff --git a/Examples/test-suite/errors/cpp_template_missing_base.i b/Examples/test-suite/errors/cpp_template_missing_base.i
new file mode 100644
index 000000000..56d44ea24
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_missing_base.i
@@ -0,0 +1,35 @@
+%module xx
+
+struct Low : High {
+};
+
+struct Small;
+
+struct Big : Small {
+};
+
+%inline %{
+namespace A {
+ class XYZ {};
+ template<typename T> struct ABC :
+ public B::ABC<T> {
+};
+}
+namespace B {
+ template<typename T> struct ABC {
+ void aaa(T t) {}
+ };
+}
+%}
+%template(ABCXYZ) A::ABC<A::XYZ>;
+
+%template() B::ABC<int>;
+%template(ABCint) A::ABC<int>;
+
+template<typename T>
+struct Another : WrongOrderBase<int> {
+};
+%template(AnotherBool) Another<bool>;
+
+template<typename T> class WrongOrderBase {};
+%template(ForAnotherInt) WrongOrderBase<int>;
diff --git a/Examples/test-suite/errors/cpp_template_missing_base.stderr b/Examples/test-suite/errors/cpp_template_missing_base.stderr
new file mode 100644
index 000000000..c76980356
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_missing_base.stderr
@@ -0,0 +1,9 @@
+cpp_template_missing_base.i:3: Warning 401: Nothing known about base class 'High'. Ignored.
+cpp_template_missing_base.i:8: Warning 402: Base class 'Small' is incomplete.
+cpp_template_missing_base.i:6: Warning 402: Only forward declaration 'Small' was found.
+cpp_template_missing_base.i:15: Warning 401: Nothing known about base class 'B::ABC< A::XYZ >'. Ignored.
+cpp_template_missing_base.i:15: Warning 401: Maybe you forgot to instantiate 'B::ABC< A::XYZ >' using %template.
+cpp_template_missing_base.i:15: Warning 401: Base class 'B::ABC< int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
+cpp_template_missing_base.i:26: Warning 401: The %template directive must be written before 'B::ABC< int >' is used as a base class and be declared with a name.
+cpp_template_missing_base.i:30: Warning 401: Base class 'WrongOrderBase< int >' undefined.
+cpp_template_missing_base.i:35: Warning 401: 'WrongOrderBase< int >' must be defined before it is used as a base class.
diff --git a/Examples/test-suite/errors/cpp_template_nargs.stderr b/Examples/test-suite/errors/cpp_template_nargs.stderr
index 4ced28e05..ef94e63e6 100644
--- a/Examples/test-suite/errors/cpp_template_nargs.stderr
+++ b/Examples/test-suite/errors/cpp_template_nargs.stderr
@@ -1,2 +1,2 @@
-cpp_template_nargs.i:5: Error: Template 'blah' undefined.
-cpp_template_nargs.i:6: Error: Template 'blah' undefined.
+cpp_template_nargs.i:5: Error: No matching function template 'blah' found.
+cpp_template_nargs.i:6: Error: No matching function template 'blah' found.
diff --git a/Examples/test-suite/errors/cpp_template_partial_specialization_defaults.i b/Examples/test-suite/errors/cpp_template_partial_specialization_defaults.i
new file mode 100644
index 000000000..25b2c5c36
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_partial_specialization_defaults.i
@@ -0,0 +1,9 @@
+%module xxx
+
+template<class Y, class T=int> struct X { void primary() {} };
+template<class YY> struct X<YY*> { void special(YY*) {} };
+
+%template(Xbad1) X<>;
+%template(Xokay1) X<const char *>;
+%template(Xokay2) X<const short *, int>;
+%template(Xbad2) X<const char *, int, double>;
diff --git a/Examples/test-suite/errors/cpp_template_partial_specialization_defaults.stderr b/Examples/test-suite/errors/cpp_template_partial_specialization_defaults.stderr
new file mode 100644
index 000000000..196862431
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_partial_specialization_defaults.stderr
@@ -0,0 +1,2 @@
+cpp_template_partial_specialization_defaults.i:6: Error: Not enough template parameters specified. Minimum of 1 required.
+cpp_template_partial_specialization_defaults.i:9: Error: Too many template parameters. Maximum of 2.
diff --git a/Examples/test-suite/errors/cpp_template_redefine.i b/Examples/test-suite/errors/cpp_template_redefine.i
new file mode 100644
index 000000000..3bd015e4b
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_redefine.i
@@ -0,0 +1,107 @@
+%module xxx
+// This is a copy of Examples/test-suite/cpp11_template_parameters_decltype
+%inline %{
+// Github issue #1589
+template <decltype(true) X = true>
+void A() { }
+%}
+
+// %template(A) A<>; // not working
+%template(A) A<true>; // workaround
+
+
+%include <std_string.i>
+%include <std_vector.i>
+%include <std_map.i>
+
+//#pragma SWIG nowarn=SWIGWARN_CPP11_DECLTYPE
+
+%{
+// Simple implementation of helper functions required in test below
+std::string array(std::vector<std::string>::const_iterator begin, std::vector<std::string>::const_iterator end) {
+ return "not implemented";
+}
+std::string object(std::map<std::string, std::string>::const_iterator begin, std::map<std::string, std::string>::const_iterator end) {
+ return "not implemented";
+}
+%}
+
+%inline %{
+#include <iostream>
+
+// Github issue #1590
+struct Converter {
+ std::string to_json() const { return std::string(); }
+};
+struct Json {
+ int ctor;
+ Json(std::string s) : ctor(0) {}
+ template < class T, class = decltype(&T::to_json) >
+ Json(const T & t) : Json(t.to_json()) { ctor = 1; }
+
+// Github issue #1589
+ // Implicit constructor: map-like objects (std::map, std::unordered_map, etc)
+ template <class M, typename std::enable_if<
+ std::is_constructible<std::string, decltype(std::declval<M>().begin()->first)>::value,
+ int>::type = 0>
+ Json(const M & m) : Json(object(m.begin(), m.end())) { ctor = 2; }
+ // Implicit constructor: vector-like objects (std::list, std::vector, std::set, etc)
+ template <class V, typename std::enable_if<
+ std::is_constructible<Json, decltype(*std::declval<V>().begin())>::value,
+ int>::type = 0>
+ Json(const V & v) : Json(array(v.begin(), v.end())) { ctor = 3; }
+
+ // Same sort of thing as constructors above but for a member function
+ int mmm(std::string s) { return 100; }
+ template < class T, class = decltype(&T::to_json) >
+ int mmm(const T & t) { return 101; }
+ template <class M, typename std::enable_if<
+ std::is_constructible<std::string, decltype(std::declval<M>().begin()->first)>::value,
+ int>::type = 0>
+ int mmm(const M & m) { return 102; }
+ template <class V, typename std::enable_if<
+ std::is_constructible<Json, decltype(*std::declval<V>().begin())>::value,
+ int>::type = 0>
+ int mmm(const V & v) { return 103; }
+};
+
+void tester(bool show) {
+ // Example usage from c++
+ if (show) {
+ Json json0(std::string("hi"));
+ Converter converter;
+ std::cout << "json0 " << json0.ctor << std::endl;
+ Json json1 = Json(converter);
+ std::cout << "json1 " << json1.ctor << std::endl;
+ std::map<std::string, std::string> myStringStringMap;
+ Json json2 = Json(myStringStringMap);
+ std::cout << "json2 " << json2.ctor << std::endl;
+ std::vector<std::string> myVectorString;
+ Json json3 = Json(myVectorString);
+ std::cout << "json3 " << json3.ctor << std::endl;
+
+ std::cout << "json0.mmm " << json0.mmm("bye") << std::endl;
+ std::cout << "json1.mmm " << json1.mmm(converter) << std::endl;
+ std::cout << "json2.mmm " << json2.mmm(myStringStringMap) << std::endl;
+ std::cout << "json3.mmm " << json3.mmm(myVectorString) << std::endl;
+ }
+}
+%}
+
+%template(VectorString) std::vector<std::string>;
+%template(MapStringString) std::map<std::string, std::string>;
+
+// There is quite a bit of inconsistency about providing or not providing default
+// template parameters that needs investigating. Below is a combination that works.
+
+// Note that instantiating the two Json constructors (or the two mmm methods) that
+// use enable_if is ambiguous given the enable_if is not evaluated by SWIG.
+
+// %template(Json) Json::Json<Converter>; // not working
+%template(Json) Json::Json<Converter, std::string>; // workaround
+%template(Json) Json::Json<std::map<std::string, std::string>, 0>;
+%template(Json) Json::Json<std::vector<std::string>, 0>;
+
+%template(mmm) Json::mmm<Converter, std::string>;
+%template(mmm) Json::mmm<std::map<std::string, std::string>, 0>;
+%template(mmm) Json::mmm<std::vector<std::string>, 0>;
diff --git a/Examples/test-suite/errors/cpp_template_redefine.stderr b/Examples/test-suite/errors/cpp_template_redefine.stderr
new file mode 100644
index 000000000..4b15c2fd8
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_template_redefine.stderr
@@ -0,0 +1,30 @@
+cpp_template_redefine.i:39: Warning 344: Unable to deduce decltype for '&T::to_json'.
+cpp_template_redefine.i:45: Warning 344: Unable to deduce decltype for 'std::declval<M>().begin()->first'.
+cpp_template_redefine.i:50: Warning 344: Unable to deduce decltype for '*std::declval<V>().begin()'.
+cpp_template_redefine.i:56: Warning 344: Unable to deduce decltype for '&T::to_json'.
+cpp_template_redefine.i:59: Warning 344: Unable to deduce decltype for 'std::declval<M>().begin()->first'.
+cpp_template_redefine.i:63: Warning 344: Unable to deduce decltype for '*std::declval<V>().begin()'.
+cpp_template_redefine.i:101: Warning 322: Redundant redeclaration of identifier 'Json' as Json::Json(Converter const &) ignored,
+cpp_template_redefine.i:101: Warning 322: previous declaration of 'Json' as Json::Json(Converter const &).
+cpp_template_redefine.i:101: Warning 322: Redundant redeclaration of identifier 'Json' as Json::Json(Converter const &) ignored,
+cpp_template_redefine.i:101: Warning 322: previous declaration of 'Json' as Json::Json(Converter const &).
+cpp_template_redefine.i:102: Warning 322: Redundant redeclaration of identifier 'Json' as Json::Json(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &) ignored,
+cpp_template_redefine.i:102: Warning 322: previous declaration of 'Json' as Json::Json(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &).
+cpp_template_redefine.i:102: Warning 322: Redundant redeclaration of identifier 'Json' as Json::Json(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &) ignored,
+cpp_template_redefine.i:102: Warning 322: previous declaration of 'Json' as Json::Json(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &).
+cpp_template_redefine.i:103: Warning 322: Redundant redeclaration of identifier 'Json' as Json::Json(std::vector< std::string,std::allocator< std::string > > const &) ignored,
+cpp_template_redefine.i:103: Warning 322: previous declaration of 'Json' as Json::Json(std::vector< std::string,std::allocator< std::string > > const &).
+cpp_template_redefine.i:103: Warning 322: Redundant redeclaration of identifier 'Json' as Json::Json(std::vector< std::string,std::allocator< std::string > > const &) ignored,
+cpp_template_redefine.i:103: Warning 322: previous declaration of 'Json' as Json::Json(std::vector< std::string,std::allocator< std::string > > const &).
+cpp_template_redefine.i:105: Warning 322: Redundant redeclaration of identifier 'mmm' as Json::mmm< Converter,std::string >(Converter const &) ignored,
+cpp_template_redefine.i:105: Warning 322: previous declaration of 'mmm' as Json::mmm< Converter,std::string >(Converter const &).
+cpp_template_redefine.i:105: Warning 322: Redundant redeclaration of identifier 'mmm' as Json::mmm< Converter,std::string >(Converter const &) ignored,
+cpp_template_redefine.i:105: Warning 322: previous declaration of 'mmm' as Json::mmm< Converter,std::string >(Converter const &).
+cpp_template_redefine.i:106: Warning 322: Redundant redeclaration of identifier 'mmm' as Json::mmm< std::map< std::string,std::string >,0 >(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &) ignored,
+cpp_template_redefine.i:106: Warning 322: previous declaration of 'mmm' as Json::mmm< std::map< std::string,std::string >,0 >(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &).
+cpp_template_redefine.i:106: Warning 322: Redundant redeclaration of identifier 'mmm' as Json::mmm< std::map< std::string,std::string >,0 >(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &) ignored,
+cpp_template_redefine.i:106: Warning 322: previous declaration of 'mmm' as Json::mmm< std::map< std::string,std::string >,0 >(std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &).
+cpp_template_redefine.i:107: Warning 322: Redundant redeclaration of identifier 'mmm' as Json::mmm< std::vector< std::string >,0 >(std::vector< std::string,std::allocator< std::string > > const &) ignored,
+cpp_template_redefine.i:107: Warning 322: previous declaration of 'mmm' as Json::mmm< std::vector< std::string >,0 >(std::vector< std::string,std::allocator< std::string > > const &).
+cpp_template_redefine.i:107: Warning 322: Redundant redeclaration of identifier 'mmm' as Json::mmm< std::vector< std::string >,0 >(std::vector< std::string,std::allocator< std::string > > const &) ignored,
+cpp_template_redefine.i:107: Warning 322: previous declaration of 'mmm' as Json::mmm< std::vector< std::string >,0 >(std::vector< std::string,std::allocator< std::string > > const &).
diff --git a/Examples/test-suite/errors/cpp_template_repeat.i b/Examples/test-suite/errors/cpp_template_repeat.i
index f170080b7..08d378223 100644
--- a/Examples/test-suite/errors/cpp_template_repeat.i
+++ b/Examples/test-suite/errors/cpp_template_repeat.i
@@ -4,4 +4,15 @@ template<class T> T blah(T x) { };
%template(iblah) blah<int>;
%template(iiblah) blah<int>;
-// The second %template instantiation above should surely be ignored with a warning, but doesn't atm
+
+// empty template instantiations for template functions warn (unlike for template classes)
+%template() blah<double>;
+%template() blah<double>;
+%template() blah<double>;
+
+%template(sblah) blah<short>;
+%template(sblah) blah<short>;
+
+%template() blah<const char *>;
+%template() blah<const char *>;
+%template(sblah) blah<const char *>;
diff --git a/Examples/test-suite/errors/cpp_template_repeat.stderr b/Examples/test-suite/errors/cpp_template_repeat.stderr
index e69de29bb..7ab04f2a3 100644
--- a/Examples/test-suite/errors/cpp_template_repeat.stderr
+++ b/Examples/test-suite/errors/cpp_template_repeat.stderr
@@ -0,0 +1,6 @@
+cpp_template_repeat.i:6: Warning 404: Duplicate template instantiation of 'blah< int >' with name 'iiblah' ignored,
+cpp_template_repeat.i:5: Warning 404: previous instantiation of 'blah< int >' with name 'iblah'.
+cpp_template_repeat.i:14: Warning 404: Duplicate template instantiation of 'blah< short >' with name 'sblah' ignored,
+cpp_template_repeat.i:13: Warning 404: previous instantiation of 'blah< short >' with name 'sblah'.
+cpp_template_repeat.i:9: Warning 519: %template() contains no name. Template method ignored: blah< double >(double)
+cpp_template_repeat.i:16: Warning 519: %template() contains no name. Template method ignored: blah< char const * >(char const *)
diff --git a/Examples/test-suite/errors/cpp_typemap_out_optimal_bug.i b/Examples/test-suite/errors/cpp_typemap_out_optimal_bug.i
new file mode 100644
index 000000000..e8168ec46
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_typemap_out_optimal_bug.i
@@ -0,0 +1,45 @@
+%module x
+
+// Just the following languages tested
+#if defined (SWIGCSHARP) || defined (SWIGD)
+%typemap(out, optimal="1") SWIGTYPE %{
+ $result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGJAVA)
+%typemap(out, optimal="1") SWIGTYPE %{
+ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGUTL)
+%typemap(out,noblock="1", optimal="1") SWIGTYPE {
+ %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
+}
+#endif
+
+// This results in an action which SWIG should disable "optimal" for, but
+// it was failing to. Fixed in SWIG 4.1.0.
+%exception XX::create() "$action\n{while(sleep(1)){}}"
+
+%ignore XX::operator=;
+
+#ifdef SWIGD
+%rename(trace) XX::debug;
+#endif
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+struct XX {
+ XX() { if (debug) cout << "XX()" << endl; }
+ XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; }
+ XX(const XX &other) { if (debug) cout << "XX(const XX &)" << endl; }
+ XX& operator =(const XX &other) { if (debug) cout << "operator=(const XX &)" << endl; return *this; }
+ ~XX() { if (debug) cout << "~XX()" << endl; }
+ static XX create() {
+ return XX(123);
+ }
+ static bool debug;
+};
+bool XX::debug = true;
+%}
+
diff --git a/Examples/test-suite/errors/cpp_typemap_out_optimal_bug.stderr b/Examples/test-suite/errors/cpp_typemap_out_optimal_bug.stderr
new file mode 100644
index 000000000..15bf64f46
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_typemap_out_optimal_bug.stderr
@@ -0,0 +1,4 @@
+cpp_typemap_out_optimal_bug.i:40: Warning 474: Method XX::create() usage of the optimal attribute ignored
+cpp_typemap_out_optimal_bug.i:15: Warning 474: in the out typemap as the following cannot be used to generate optimal code: result = XX::create();
+{while(sleep(1)){}}
+
diff --git a/Examples/test-suite/errors/cpp_using_constructor_bad.i b/Examples/test-suite/errors/cpp_using_constructor_bad.i
new file mode 100644
index 000000000..19b7eaa7e
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_constructor_bad.i
@@ -0,0 +1,22 @@
+%module xxx
+
+struct NotConnected {};
+struct Base {};
+struct Derived : Base {};
+struct MoreDerived : Derived {
+ using Base::Base;
+ using NotConnected::NotConnected;
+};
+
+template<typename T>
+struct TemplateBase {};
+template<typename T>
+struct TemplateDerived : TemplateBase<T> {};
+template<typename T>
+struct TemplateMoreDerived : TemplateDerived<T> {
+ using TemplateBase<T>::TemplateBase;
+};
+
+%template(TemplateBaseInt) TemplateBase<int>;
+%template(TempDerivedInt) TemplateDerived<int>;
+%template(TempMoreDerivedInt) TemplateMoreDerived<int>;
diff --git a/Examples/test-suite/errors/cpp_using_constructor_bad.stderr b/Examples/test-suite/errors/cpp_using_constructor_bad.stderr
new file mode 100644
index 000000000..e635d2089
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_constructor_bad.stderr
@@ -0,0 +1,3 @@
+cpp_using_constructor_bad.i:7: Warning 329: Using declaration 'Base::Base' for inheriting constructors uses base 'Base' which is not an immediate base of 'MoreDerived'.
+cpp_using_constructor_bad.i:8: Warning 329: Using declaration 'NotConnected::NotConnected' for inheriting constructors uses base 'NotConnected' which is not an immediate base of 'MoreDerived'.
+cpp_using_constructor_bad.i:17: Warning 329: Using declaration 'TemplateBase< int >::TemplateBase' for inheriting constructors uses base 'TemplateBase' which is not an immediate base of 'TemplateMoreDerived< int >'.
diff --git a/Examples/test-suite/errors/cpp_using_declaration_overload.i b/Examples/test-suite/errors/cpp_using_declaration_overload.i
new file mode 100644
index 000000000..9ec633f3f
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_declaration_overload.i
@@ -0,0 +1,9 @@
+%module xxx
+
+struct Base {
+ void m(bool) {}
+};
+struct Derived : Base {
+ void m(bool) const {}
+ using Base::m;
+};
diff --git a/Examples/test-suite/errors/cpp_using_declaration_overload.stderr b/Examples/test-suite/errors/cpp_using_declaration_overload.stderr
new file mode 100644
index 000000000..a5118a739
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_declaration_overload.stderr
@@ -0,0 +1,2 @@
+cpp_using_declaration_overload.i:7: Warning 512: Overloaded method Derived::m(bool) const ignored,
+cpp_using_declaration_overload.i:8: Warning 512: using non-const method Derived::m(bool) instead.
diff --git a/Examples/test-suite/errors/cpp_using_rename.i b/Examples/test-suite/errors/cpp_using_rename.i
new file mode 100644
index 000000000..4b6453ca0
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_rename.i
@@ -0,0 +1,22 @@
+%module xxx
+
+%rename(UseMe) use_me(int i);
+%rename(UseMeToo) Derived::use_me_too;
+
+class Base
+{
+public:
+ void use_me(Base *);
+ void use_me(int i);
+ bool use_me_too(double d) const;
+ bool use_me_too(bool b) const;
+};
+
+class Derived : public Base
+{
+public:
+ using Base::use_me;
+ using Base::use_me_too;
+ using Base::does_not_exist;
+};
+
diff --git a/Examples/test-suite/errors/cpp_using_rename.stderr b/Examples/test-suite/errors/cpp_using_rename.stderr
new file mode 100644
index 000000000..546489655
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_using_rename.stderr
@@ -0,0 +1,7 @@
+cpp_using_rename.i:18: Warning 526: Using declaration Base::use_me, with name 'use_me', is not actually using
+cpp_using_rename.i:10: Warning 526: the method from Base::use_me(int), with name 'UseMe', as the names are different.
+cpp_using_rename.i:19: Warning 526: Using declaration Base::use_me_too, with name 'UseMeToo', is not actually using
+cpp_using_rename.i:11: Warning 526: the method from Base::use_me_too(double) const, with name 'use_me_too', as the names are different.
+cpp_using_rename.i:19: Warning 526: Using declaration Base::use_me_too, with name 'UseMeToo', is not actually using
+cpp_using_rename.i:12: Warning 526: the method from Base::use_me_too(bool) const, with name 'use_me_too', as the names are different.
+cpp_using_rename.i:20: Warning 315: Nothing known about 'Base::does_not_exist'.
diff --git a/Examples/test-suite/errors/doxygen_unclosed_tag.i b/Examples/test-suite/errors/doxygen_unclosed_tag.i
new file mode 100644
index 000000000..fbc359627
--- /dev/null
+++ b/Examples/test-suite/errors/doxygen_unclosed_tag.i
@@ -0,0 +1,6 @@
+%module xxx
+
+/**
+ * Return a random variate with uniform distribution in the range [a,b), where a<b
+ */
+double uniform(double a, double b);
diff --git a/Examples/test-suite/errors/doxygen_unclosed_tag.stderr b/Examples/test-suite/errors/doxygen_unclosed_tag.stderr
new file mode 100644
index 000000000..9fcdbbbe8
--- /dev/null
+++ b/Examples/test-suite/errors/doxygen_unclosed_tag.stderr
@@ -0,0 +1 @@
+doxygen_unclosed_tag.i:4: Warning 563: Doxygen HTML error for tag b: HTML tag without greater-than ('>') found.
diff --git a/Examples/test-suite/errors/pp_badeval.stderr b/Examples/test-suite/errors/pp_badeval.stderr
index 80f5037ea..bfaa17f59 100644
--- a/Examples/test-suite/errors/pp_badeval.stderr
+++ b/Examples/test-suite/errors/pp_badeval.stderr
@@ -1,2 +1,2 @@
pp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+'
-pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
+pp_badeval.i:4: Warning 202: Expected an expression
diff --git a/Examples/test-suite/errors/pp_deprecated.stderr b/Examples/test-suite/errors/pp_deprecated.stderr
deleted file mode 100644
index 6eff001ac..000000000
--- a/Examples/test-suite/errors/pp_deprecated.stderr
+++ /dev/null
@@ -1,4 +0,0 @@
-pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
-pp_deprecated.i:4: Error: Unable to find 'ext;'
-pp_deprecated.i:6: Warning 204: CPP #warning, "Print this warning".
-pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
diff --git a/Examples/test-suite/errors/pp_deprecated.i b/Examples/test-suite/errors/pp_error_directive.i
index 68f81317b..851528418 100644
--- a/Examples/test-suite/errors/pp_deprecated.i
+++ b/Examples/test-suite/errors/pp_error_directive.i
@@ -1,9 +1,9 @@
%module xxx
-
-%extern ext;
-
#warning Print this warning
#error This is an error
+#error Another error
+
+#warning Another warning
diff --git a/Examples/test-suite/errors/pp_error_directive.stderr b/Examples/test-suite/errors/pp_error_directive.stderr
new file mode 100644
index 000000000..9e3523aeb
--- /dev/null
+++ b/Examples/test-suite/errors/pp_error_directive.stderr
@@ -0,0 +1,4 @@
+pp_error_directive.i:3: Warning 204: CPP #warning, "Print this warning".
+pp_error_directive.i:5: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
+pp_error_directive.i:7: Error: CPP #error "Another error". Use the -cpperraswarn option to continue swig processing.
+pp_error_directive.i:9: Warning 204: CPP #warning, "Another warning".
diff --git a/Examples/test-suite/errors/pp_expressions_bad.i b/Examples/test-suite/errors/pp_expressions_bad.i
index 454437f95..8f1929e32 100644
--- a/Examples/test-suite/errors/pp_expressions_bad.i
+++ b/Examples/test-suite/errors/pp_expressions_bad.i
@@ -1,5 +1,5 @@
%module xxx
-/* Note: needs -Wextra to see these warnings */
+
/* Divide by zero */
#define ZERO 0
@@ -41,3 +41,39 @@
#if(1)
#warning Warning okay: #if(1)
#endif
+
+/* The SWIG preprocessor support strings with equality/inequality tests.
+ * Check error cases.
+ */
+#if "TWO" == 1
+#endif
+
+/* This didn't fail prior with SWIG < 4.1. Github #1384. */
+#if 1 == ("TWO")
+#endif
+
+/* These should all give errors. */
+#if "1"
+#endif
+#if -"1"
+#endif
+#if "1" == -"-1"
+#endif
+#if "1" == !"-1"
+#endif
+#if "1" == ~"1"
+#endif
+/* Unary + was a no-op and so this didn't give an error in SWIG < 4.1.0. */
+#if "1" == +"1"
+#endif
+
+/* Spaceship operator doesn't seem to be allowed in preprocessor expressions,
+ * and isn't valid in C at all.
+ */
+#if (4 <=> 2) < 0
+#endif
+
+/* Check handling of use of an undefined function-like macro. */
+#if MY_VERSION_AT_LEAST(1,2,3)
+#warning This should not warn
+#endif
diff --git a/Examples/test-suite/errors/pp_expressions_bad.stderr b/Examples/test-suite/errors/pp_expressions_bad.stderr
index 84104c6a8..23c641621 100644
--- a/Examples/test-suite/errors/pp_expressions_bad.stderr
+++ b/Examples/test-suite/errors/pp_expressions_bad.stderr
@@ -1,19 +1,37 @@
pp_expressions_bad.i:7: Warning 202: Could not evaluate expression '1%ZERO'
-pp_expressions_bad.i:7: Warning 202: Error: 'Modulo by zero in expression'
+pp_expressions_bad.i:7: Warning 202: Modulo by zero in expression
pp_expressions_bad.i:9: Warning 202: Could not evaluate expression '2/ZERO'
-pp_expressions_bad.i:9: Warning 202: Error: 'Division by zero in expression'
+pp_expressions_bad.i:9: Warning 202: Division by zero in expression
pp_expressions_bad.i:12: Warning 202: Could not evaluate expression '1%(5-5)'
-pp_expressions_bad.i:12: Warning 202: Error: 'Modulo by zero in expression'
+pp_expressions_bad.i:12: Warning 202: Modulo by zero in expression
pp_expressions_bad.i:14: Warning 202: Could not evaluate expression '2/(55-55)'
-pp_expressions_bad.i:14: Warning 202: Error: 'Division by zero in expression'
+pp_expressions_bad.i:14: Warning 202: Division by zero in expression
pp_expressions_bad.i:18: Warning 202: Could not evaluate expression '1.2'
-pp_expressions_bad.i:18: Warning 202: Error: 'Floating point constant in preprocessor expression'
+pp_expressions_bad.i:18: Warning 202: Floating point constant in preprocessor expression
pp_expressions_bad.i:21: Warning 202: Could not evaluate expression '2e3'
-pp_expressions_bad.i:21: Warning 202: Error: 'Floating point constant in preprocessor expression'
+pp_expressions_bad.i:21: Warning 202: Floating point constant in preprocessor expression
pp_expressions_bad.i:25: Warning 202: Could not evaluate expression '8.8'
-pp_expressions_bad.i:25: Warning 202: Error: 'Floating point constant in preprocessor expression'
+pp_expressions_bad.i:25: Warning 202: Floating point constant in preprocessor expression
pp_expressions_bad.i:29: Error: Unknown SWIG preprocessor directive: if123 (if this is a block of target language code, delimit it with %{ and %})
pp_expressions_bad.i:30: Error: Extraneous #endif.
pp_expressions_bad.i:32: Error: Unknown SWIG preprocessor directive: if456e (if this is a block of target language code, delimit it with %{ and %})
pp_expressions_bad.i:33: Error: Extraneous #endif.
pp_expressions_bad.i:42: Warning 204: CPP #warning, "Warning okay: #if(1)".
+pp_expressions_bad.i:48: Warning 202: Could not evaluate expression '"TWO" == 1'
+pp_expressions_bad.i:48: Warning 202: Can't mix strings and integers in expression
+pp_expressions_bad.i:52: Warning 202: Could not evaluate expression '1 == ("TWO")'
+pp_expressions_bad.i:52: Warning 202: Can't mix strings and integers in expression
+pp_expressions_bad.i:58: Warning 202: Could not evaluate expression '-"1"'
+pp_expressions_bad.i:58: Warning 202: Syntax error: attempt to apply unary operator to string
+pp_expressions_bad.i:60: Warning 202: Could not evaluate expression '"1" == -"-1"'
+pp_expressions_bad.i:60: Warning 202: Syntax error: attempt to apply unary operator to string
+pp_expressions_bad.i:62: Warning 202: Could not evaluate expression '"1" == !"-1"'
+pp_expressions_bad.i:62: Warning 202: Syntax error: attempt to apply unary operator to string
+pp_expressions_bad.i:64: Warning 202: Could not evaluate expression '"1" == ~"1"'
+pp_expressions_bad.i:64: Warning 202: Syntax error: attempt to apply unary operator to string
+pp_expressions_bad.i:67: Warning 202: Could not evaluate expression '"1" == +"1"'
+pp_expressions_bad.i:67: Warning 202: Syntax error: attempt to apply unary operator to string
+pp_expressions_bad.i:73: Warning 202: Could not evaluate expression '(4 <=> 2) < 0'
+pp_expressions_bad.i:73: Warning 202: Syntax error
+pp_expressions_bad.i:77: Warning 202: Could not evaluate expression 'MY_VERSION_AT_LEAST(1,2,3)'
+pp_expressions_bad.i:77: Warning 202: Use of undefined function-like macro
diff --git a/Examples/test-suite/errors/pp_invalid_exponents.stderr b/Examples/test-suite/errors/pp_invalid_exponents.stderr
index 735a31ceb..2ad1b5c6b 100644
--- a/Examples/test-suite/errors/pp_invalid_exponents.stderr
+++ b/Examples/test-suite/errors/pp_invalid_exponents.stderr
@@ -1,6 +1,6 @@
:EOF: Error: Exponent does not have any digits
pp_invalid_exponents.i:3: Warning 202: Could not evaluate expression '123e'
-pp_invalid_exponents.i:3: Warning 202: Error: 'Syntax error'
+pp_invalid_exponents.i:3: Warning 202: Syntax error
:EOF: Error: Exponent does not have any digits
pp_invalid_exponents.i:6: Warning 202: Could not evaluate expression '456.e'
-pp_invalid_exponents.i:6: Warning 202: Error: 'Syntax error'
+pp_invalid_exponents.i:6: Warning 202: Syntax error
diff --git a/Examples/test-suite/errors/pp_unknowndirective.i b/Examples/test-suite/errors/pp_unknowndirective.i
index b4e608b34..659a997d3 100644
--- a/Examples/test-suite/errors/pp_unknowndirective.i
+++ b/Examples/test-suite/errors/pp_unknowndirective.i
@@ -1,10 +1,5 @@
%module xxx
-/* Regression test for bug introduced in 3.0.4 and fixed in 3.0.6 - the '%std'
- * here led to SWIG calling abort().
- */
-%typemap(jstype) std::vector<std::string>, const %std::vector<std::string>&, std::vector<std::string>& "List<String>"
-
/* This used to give the rather cryptic "Syntax error in input(1)." prior to
* SWIG 3.0.4. This testcase checks that the improved message is actually
* issued.
diff --git a/Examples/test-suite/errors/pp_unknowndirective.stderr b/Examples/test-suite/errors/pp_unknowndirective.stderr
index 2cc2377c7..d0d5e249f 100644
--- a/Examples/test-suite/errors/pp_unknowndirective.stderr
+++ b/Examples/test-suite/errors/pp_unknowndirective.stderr
@@ -1 +1 @@
-pp_unknowndirective.i:12: Error: Unknown directive '%remane'.
+pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
diff --git a/Examples/test-suite/errors/pp_unknowndirective4.i b/Examples/test-suite/errors/pp_unknowndirective4.i
new file mode 100644
index 000000000..c9d95e1f0
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective4.i
@@ -0,0 +1,7 @@
+%module xxx
+
+/* Regression test for bug #368 introduced in 3.0.4 and fully fixed in 4.1.0.
+ * The `%std` here led to SWIG calling abort() before 3.0.6, and was quietly
+ * ignored in from 3.0.6 until 4.1.0.
+ */
+%typemap(jstype) std::vector<std::string>, const %std::vector<std::string>&, std::vector<std::string>& "List<String>"
diff --git a/Examples/test-suite/errors/pp_unknowndirective4.stderr b/Examples/test-suite/errors/pp_unknowndirective4.stderr
new file mode 100644
index 000000000..efb6afe6e
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective4.stderr
@@ -0,0 +1 @@
+pp_unknowndirective4.i:7: Error: Unknown directive '%std'.
diff --git a/Examples/test-suite/errors/pp_unknowndirective5.i b/Examples/test-suite/errors/pp_unknowndirective5.i
new file mode 100644
index 000000000..f5fb0f5e7
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective5.i
@@ -0,0 +1,20 @@
+%module xxx
+
+/* Before SWIG 4.1.0 the `9%a` expression triggered:
+ *
+ * Error: Unknown directive '%a'
+ *
+ * The fix for that works by handling an apparent directive that isn't a
+ * recognised directive by noting down its name, emitting MODULO and then
+ * rescanning what follows, and if the parser then gives a syntax error we
+ * report it as an unknown directive.
+ *
+ * However the initial version of this failed to reset the noted down apparent
+ * directive often enough, so a later syntax error could get incorrectly
+ * reported. Here the syntax error in the declaration of `c` was confusingly
+ * reported as `Error: Unknown directive '%a'`. This was found and fixed prior
+ * to 4.1.0.
+ */
+int a;
+int test2(int b = 9%a) { return b; }
+void int c;
diff --git a/Examples/test-suite/errors/pp_unknowndirective5.stderr b/Examples/test-suite/errors/pp_unknowndirective5.stderr
new file mode 100644
index 000000000..b61c3addb
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective5.stderr
@@ -0,0 +1 @@
+pp_unknowndirective5.i:20: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/swig_command_encoder.i b/Examples/test-suite/errors/swig_command_encoder.i
new file mode 100644
index 000000000..aaae82bb5
--- /dev/null
+++ b/Examples/test-suite/errors/swig_command_encoder.i
@@ -0,0 +1,6 @@
+%module xxx
+
+// This feature was removed in SWIG 4.1.0 so check it gives an error.
+%define SedCmd "%(command:sed -e 's/\([a-z]\)/\U\\1/' -e 's/\(_\)\([a-z]\)/\U\\2/g' <<<)s" %enddef
+%rename(SedCmd) "";
+int x;
diff --git a/Examples/test-suite/errors/swig_command_encoder.stderr b/Examples/test-suite/errors/swig_command_encoder.stderr
new file mode 100644
index 000000000..247924623
--- /dev/null
+++ b/Examples/test-suite/errors/swig_command_encoder.stderr
@@ -0,0 +1 @@
+SWIG:EOF: Error: Command encoder no longer supported - use regex encoder instead, command:sed -e 's//([a-z]/)//U/1/' -e 's//(_/)/([a-z]/)//U/2/g' <<<x
diff --git a/Examples/test-suite/errors/swig_constant_missing_semi.i b/Examples/test-suite/errors/swig_constant_missing_semi.i
new file mode 100644
index 000000000..3fa1f3bd2
--- /dev/null
+++ b/Examples/test-suite/errors/swig_constant_missing_semi.i
@@ -0,0 +1,3 @@
+%module xxx
+%constant int BAR=0
+int foo(int);
diff --git a/Examples/test-suite/errors/swig_constant_missing_semi.stderr b/Examples/test-suite/errors/swig_constant_missing_semi.stderr
new file mode 100644
index 000000000..f86d37356
--- /dev/null
+++ b/Examples/test-suite/errors/swig_constant_missing_semi.stderr
@@ -0,0 +1 @@
+swig_constant_missing_semi.i:3: Warning 305: Bad constant value (ignored).
diff --git a/Examples/test-suite/errors/swig_typemap_missing_value.i b/Examples/test-suite/errors/swig_typemap_missing_value.i
new file mode 100644
index 000000000..b9937af1a
--- /dev/null
+++ b/Examples/test-suite/errors/swig_typemap_missing_value.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%typemap(in, numinputs=1, foo) int ""
+%typemap(argout=123) char* ""
+
+/* SWIG segfaulted trying to use the above in typemap in SWIG < 4.1.0. */
+void func(int arg);
diff --git a/Examples/test-suite/errors/swig_typemap_missing_value.stderr b/Examples/test-suite/errors/swig_typemap_missing_value.stderr
new file mode 100644
index 000000000..26bc8cdb9
--- /dev/null
+++ b/Examples/test-suite/errors/swig_typemap_missing_value.stderr
@@ -0,0 +1,2 @@
+swig_typemap_missing_value.i:3: Error: %typemap attribute 'foo' is missing its value. If this is specifying the target language, that's no longer supported: use #ifdef SWIG<LANG> instead.
+swig_typemap_missing_value.i:4: Error: %typemap method shouldn't have a value specified.
diff --git a/Examples/test-suite/errors/swig_typemap_old.stderr b/Examples/test-suite/errors/swig_typemap_old.stderr
index 23741164e..91bf1151d 100644
--- a/Examples/test-suite/errors/swig_typemap_old.stderr
+++ b/Examples/test-suite/errors/swig_typemap_old.stderr
@@ -1,5 +1,5 @@
-swig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target).
-swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated.
+swig_typemap_old.i:6: Error: Obsolete typemap feature ($source/$target).
+swig_typemap_old.i:6: Error: The use of $source and $target in a typemap declaration is no longer supported.
For typemaps related to argument input (in,ignore,default,arginit,check), replace
$source by $input and $target by $1. For typemaps related to return values (out,
argout,ret,except), replace $source by $1 and $target by $result. See the file