aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.current13
-rw-r--r--Doc/Manual/SWIGPlus.html6
-rw-r--r--Examples/test-suite/errors/cpp_inherit.i8
-rw-r--r--Examples/test-suite/errors/expected.log4
-rw-r--r--Source/Modules/lang.cxx2
-rw-r--r--Source/Modules/typepass.cxx11
6 files changed, 37 insertions, 7 deletions
diff --git a/CHANGES.current b/CHANGES.current
index cd8ad4e87..a4a049b1d 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -4,6 +4,19 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.9 (in progress)
===========================
+2012-09-14: wsfulton
+ Add new warning if the empty template instantiation is used as a base class, for example:
+
+ template <typename T> class Base {};
+ %template() Base<int>;
+ class Derived : public Base<int> {};
+
+ gives the following warning instead of silently ignoring the base:
+
+ cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
+ cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name.
+
+
2012-09-11: wsfulton
[Java] Fix #3535304 - Direct use of a weak global reference in directors
sometimes causing seg faults especially on Android.
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index b4baca6ae..9ecf0aa5a 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -3121,8 +3121,8 @@ nothing is known about <tt>List&lt;int&gt;</tt>, you will get a warning message
<div class="shell">
<pre>
-example.h:42. Nothing known about class 'List&lt;int &gt;' (ignored).
-example.h:42. Maybe you forgot to instantiate 'List&lt;int &gt;' using %template.
+example.h:42: Warning 401. Nothing known about class 'List&lt;int &gt;'. Ignored.
+example.h:42: Warning 401. Maybe you forgot to instantiate 'List&lt;int &gt;' using %template.
</pre>
</div>
@@ -3163,7 +3163,7 @@ Don't worry--if you get the order wrong, SWIG should generate a warning message.
Occasionally, you may need to tell SWIG about base classes that are defined by templates,
but which aren't supposed to be wrapped. Since SWIG is not able to automatically
instantiate templates for this purpose, you must do it manually. To do this, simply
-use <tt>%template</tt> with no name. For example:
+use the empty template instantiation, that is, <tt>%template</tt> with no name. For example:
</p>
<div class="code">
diff --git a/Examples/test-suite/errors/cpp_inherit.i b/Examples/test-suite/errors/cpp_inherit.i
index fdc77d1d5..1155715e5 100644
--- a/Examples/test-suite/errors/cpp_inherit.i
+++ b/Examples/test-suite/errors/cpp_inherit.i
@@ -45,3 +45,11 @@ struct Recursive : Recursive
{
};
%}
+
+
+template <typename T> class Base {};
+%template() Base<int>;
+class Derived : public Base<int> {};
+class Derived2 : public Base<double> {};
+%template(BaseDouble) Base<double>;
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index bcaf4efd8..4f56e7146 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -268,6 +268,10 @@ cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
+cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored.
+cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name.
+cpp_inherit.i:53: Warning 401: Base class 'Base< double >' undefined.
+cpp_inherit.i:54: Warning 401: 'Base< double >' must be defined before it is used as a base class.
:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index e81ab21dd..d15d650a2 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -965,7 +965,7 @@ int Language::cDeclaration(Node *n) {
DohIncref(type);
Setattr(n, "type", ty);
if (GetFlag(n, "feature:onlychildren") && !GetFlag(n, "feature:ignore")) {
- // Found an unignored templated method that has a an empty template instantiation (%template())
+ // Found an unignored templated method that has an empty template instantiation (%template())
// Ignore it unless it has been %rename'd
if (Strncmp(symname, "__dummy_", 8) == 0) {
SetFlag(n, "feature:ignore");
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 3284a669a..a134e0ac6 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -185,9 +185,14 @@ class TypePass:private Dispatcher {
bcls = 0;
} else {
if (Getattr(bcls, "typepass:visit")) {
- if (!ilist)
- ilist = alist = NewList();
- Append(ilist, bcls);
+ if (!Getattr(bcls, "feature:onlychildren")) {
+ if (!ilist)
+ ilist = alist = NewList();
+ Append(ilist, bcls);
+ } else {
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
+ }
} else {
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));