Add new warning if an empty template declaration is used on a base class, minor docs improvement for empty template declarations.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13840 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
323f841d93
commit
bc43673a86
6 changed files with 37 additions and 7 deletions
|
|
@ -4,6 +4,19 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
Version 2.0.9 (in progress)
|
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
|
2012-09-11: wsfulton
|
||||||
[Java] Fix #3535304 - Direct use of a weak global reference in directors
|
[Java] Fix #3535304 - Direct use of a weak global reference in directors
|
||||||
sometimes causing seg faults especially on Android.
|
sometimes causing seg faults especially on Android.
|
||||||
|
|
|
||||||
|
|
@ -3121,8 +3121,8 @@ nothing is known about <tt>List<int></tt>, you will get a warning message
|
||||||
|
|
||||||
<div class="shell">
|
<div class="shell">
|
||||||
<pre>
|
<pre>
|
||||||
example.h:42. Nothing known about class 'List<int >' (ignored).
|
example.h:42: Warning 401. Nothing known about class 'List<int >'. Ignored.
|
||||||
example.h:42. Maybe you forgot to instantiate 'List<int >' using %template.
|
example.h:42: Warning 401. Maybe you forgot to instantiate 'List<int >' using %template.
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</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,
|
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
|
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
|
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>
|
</p>
|
||||||
|
|
||||||
<div class="code">
|
<div class="code">
|
||||||
|
|
|
||||||
|
|
@ -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>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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: 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: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: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 :::::::::::::::::::::::::::::::::::
|
||||||
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
|
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
|
||||||
|
|
|
||||||
|
|
@ -965,7 +965,7 @@ int Language::cDeclaration(Node *n) {
|
||||||
DohIncref(type);
|
DohIncref(type);
|
||||||
Setattr(n, "type", ty);
|
Setattr(n, "type", ty);
|
||||||
if (GetFlag(n, "feature:onlychildren") && !GetFlag(n, "feature:ignore")) {
|
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
|
// Ignore it unless it has been %rename'd
|
||||||
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
||||||
SetFlag(n, "feature:ignore");
|
SetFlag(n, "feature:ignore");
|
||||||
|
|
|
||||||
|
|
@ -185,9 +185,14 @@ class TypePass:private Dispatcher {
|
||||||
bcls = 0;
|
bcls = 0;
|
||||||
} else {
|
} else {
|
||||||
if (Getattr(bcls, "typepass:visit")) {
|
if (Getattr(bcls, "typepass:visit")) {
|
||||||
if (!ilist)
|
if (!Getattr(bcls, "feature:onlychildren")) {
|
||||||
ilist = alist = NewList();
|
if (!ilist)
|
||||||
Append(ilist, bcls);
|
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 {
|
} 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(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));
|
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));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue