Don't generate constructor wrappers if a base class has a private constructor

g++-5 errors out with this now with errors such as:

default_constructor_wrap.cxx:665:27: error: use of deleted function ‘FFF::FFF()’
   result = (FFF *)new FFF();
                           ^
default_constructor_wrap.cxx:314:7: note: ‘FFF::FFF()’ is implicitly deleted because the default definition would be ill-formed:
 class FFF : public F {
       ^
default_constructor_wrap.cxx:301:4: error: ‘F::~F()’ is private
    ~F() { }
    ^
default_constructor_wrap.cxx:314:7: error: within this context
This commit is contained in:
William S Fulton 2015-07-07 20:15:55 +01:00
commit 3718b810c7
13 changed files with 45 additions and 72 deletions

View file

@ -12,13 +12,5 @@ public class runme
throw new Exception("Protected destructor exception should have been thrown");
} catch (MethodAccessException) {
}
// calling private destructor test
try {
using (FFF f = new FFF()) {
}
throw new Exception("Private destructor exception should have been thrown");
} catch (MethodAccessException) {
}
}
}

View file

@ -1,6 +1,5 @@
module default_constructor_runme;
import default_constructor.FFF;
import default_constructor.G;
void main() {
@ -15,16 +14,4 @@ void main() {
throw e;
}
}
// Private destructor test.
try {
{
scope f = new FFF();
}
throw new Exception("Private destructor exception should have been thrown");
} catch (Exception e) {
if (e.msg != "C++ destructor does not have public access") {
throw e;
}
}
}

View file

@ -1,6 +1,5 @@
module default_constructor_runme;
import default_constructor.FFF;
import default_constructor.G;
void main() {
@ -8,7 +7,6 @@ void main() {
// destruction yet.
// enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
// enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
}
private void enforceThrows(void delegate() dg, string errorMessage) {

View file

@ -13,6 +13,16 @@
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) GGG; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) HHH; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
%delobject F::destroy;
@ -103,14 +113,15 @@ public:
void bar(F *) { }
#if defined(_MSC_VER)
#pragma warning(disable: 4624) // : destructor could not be generated because a base class destructor is inaccessible
#endif
// Single inheritance, base has private destructor
class FFF : public F {
};
#if defined(_MSC_VER)
#pragma warning(default: 4624) // : destructor could not be generated because a base class destructor is inaccessible
#endif
// Multiple inheritance, one base has private destructor
class GGG : public A, public F {
};
class HHH : public F, public A {
};
/* A class with a protected destructor */
class G {

View file

@ -21,9 +21,6 @@ func main() {
f := dc.NewF()
f.Destroy()
ff := dc.NewFFF()
ff.Destroy()
g := dc.NewG()
dc.GDestroy(g)

View file

@ -20,13 +20,5 @@ public class default_constructor_runme {
throw new RuntimeException("Protected destructor exception should have been thrown");
} catch (UnsupportedOperationException e) {
}
// calling private destructor test
try {
FFF f = new FFF();
f.delete();
throw new RuntimeException("Private destructor exception should have been thrown");
} catch (UnsupportedOperationException e) {
}
}
}

View file

@ -83,15 +83,6 @@ end_try_catch
dc.F_destroy(f);
ff = dc.new_FFF();
try
del_ff = dc.delete_FFF;
error("Whoa. delete_FFF created")
catch
end_try_catch
dc.F_destroy(ff);
g = dc.new_G();
try

View file

@ -89,15 +89,6 @@ except AttributeError:
dc.F_destroy(f)
ff = dc.new_FFF()
try:
del_ff = dc.delete_FFF
print "Whoa. delete_FFF created"
except AttributeError:
pass
dc.F_destroy(ff)
g = dc.new_G()
try:

View file

@ -143,9 +143,6 @@ end
# This should work fine
f = F.new
# This should work fine
ff = FFF.new
# This should work fine
g = G.new

View file

@ -84,15 +84,6 @@ end
F_destroy(f);
ff = new_FFF();
try
del_ff = delete_FFF;
swigtesterror("delete_FFF created")
catch
end
F_destroy(ff);
g = new_G();
try