Skip to content

Commit 49122e0

Browse files
committed
Generate valid C++ for protected ctors of pure classes
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 42f38ec commit 49122e0

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/Generator/Passes/SymbolsCodeGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ private void WrapConstructor(Method method, string wrapper, string @params)
157157
Write("extern \"C\" ");
158158
Write($"{GetExporting()}void {wrapper}({signature}) ");
159159

160-
if (method.Access == AccessSpecifier.Protected ||
161-
((Class) method.Namespace).IsAbstract)
160+
bool isAbstract = ((Class) method.Namespace).IsAbstract;
161+
if (method.Access == AccessSpecifier.Protected || isAbstract)
162162
{
163163
Write($@"{{ ::new ({Helpers.InstanceField}) {
164164
wrapper}{method.Namespace.Name}({@params}); }}");
165-
WriteLine(method.Access == AccessSpecifier.Protected ? " };" : string.Empty);
165+
WriteLine(!isAbstract ? " };" : string.Empty);
166166
}
167167
else
168168
{

tests/CSharp/CSharp.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,6 @@ int MethodsWithDefaultValues::getA()
832832
return m_foo.A;
833833
}
834834

835-
HasPureVirtualWithDefaultArg::~HasPureVirtualWithDefaultArg()
836-
{
837-
}
838-
839835
HasOverridesWithChangedAccessBase::HasOverridesWithChangedAccessBase()
840836
{
841837
}

tests/CSharp/CSharp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,14 @@ class DLL_API MethodsWithDefaultValues : public Quux
489489
Foo m_foo;
490490
};
491491

492-
class DLL_API HasPureVirtualWithDefaultArg
492+
// don't export this one or the bug doesn't reproduce on windows
493+
class HasPureVirtualWithDefaultArg
493494
{
494495
public:
495-
virtual ~HasPureVirtualWithDefaultArg();
496+
virtual ~HasPureVirtualWithDefaultArg() {}
496497
virtual void pureVirtualWithDefaultArg(Foo* foo = nullptr) = 0;
498+
protected:
499+
HasPureVirtualWithDefaultArg() {}
497500
};
498501

499502
class DLL_API HasOverridesWithChangedAccessBase

0 commit comments

Comments
 (0)