Skip to content

Commit 92da301

Browse files
committed
Fixed the generation when a secondary base is used in more than one unit.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent 4a34af1 commit 92da301

File tree

6 files changed

+74
-58
lines changed

6 files changed

+74
-58
lines changed

src/Generator/Passes/MultipleInheritancePass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public MultipleInheritancePass()
2727
VisitOptions.VisitFunctionParameters = false;
2828
}
2929

30-
public override bool VisitTranslationUnit(TranslationUnit unit)
30+
public override bool VisitASTContext(ASTContext context)
3131
{
32-
bool result = base.VisitTranslationUnit(unit);
32+
bool result = base.VisitASTContext(context);
3333
foreach (var @interface in interfaces.Where(i => !(i is ClassTemplateSpecialization)))
3434
{
3535
int index = @interface.Namespace.Declarations.IndexOf(@interface.OriginalClass);

tests/CSharp/AnotherUnit.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,47 @@
11
#include "AnotherUnit.h"
22

3+
void SecondaryBase::VirtualMember()
4+
{
5+
}
6+
7+
int SecondaryBase::property()
8+
{
9+
return 0;
10+
}
11+
12+
void SecondaryBase::setProperty(int value)
13+
{
14+
}
15+
16+
void SecondaryBase::function(bool* ok)
17+
{
18+
}
19+
20+
void SecondaryBase::protectedFunction()
21+
{
22+
}
23+
24+
int SecondaryBase::protectedProperty()
25+
{
26+
return 0;
27+
}
28+
29+
void SecondaryBase::setProtectedProperty(int value)
30+
{
31+
}
32+
333
void functionInAnotherUnit()
434
{
535
}
636

37+
MultipleInheritance::MultipleInheritance()
38+
{
39+
}
40+
41+
MultipleInheritance::~MultipleInheritance()
42+
{
43+
}
44+
745
namespace HasFreeConstant
846
{
947
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE = 5;

tests/CSharp/AnotherUnit.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33

44
#pragma once
55

6+
class DLL_API SecondaryBase
7+
{
8+
public:
9+
enum Property
10+
{
11+
P1,
12+
P2
13+
};
14+
enum Function
15+
{
16+
M1,
17+
M2
18+
};
19+
20+
virtual void VirtualMember();
21+
int property();
22+
void setProperty(int value);
23+
void function(bool* ok = 0);
24+
typedef void HasPointerToEnum(Property* pointerToEnum);
25+
HasPointerToEnum* hasPointerToEnum;
26+
protected:
27+
void protectedFunction();
28+
int protectedProperty();
29+
void setProtectedProperty(int value);
30+
};
31+
632
void DLL_API functionInAnotherUnit();
733

834
struct DLL_API ForwardDeclaredStruct;
@@ -19,6 +45,13 @@ class ForwardInOtherUnitButSameModule
1945
{
2046
};
2147

48+
class DLL_API MultipleInheritance : ForwardInOtherUnitButSameModule, SecondaryBase
49+
{
50+
public:
51+
MultipleInheritance();
52+
~MultipleInheritance();
53+
};
54+
2255
namespace HasFreeConstant
2356
{
2457
extern const int DLL_API FREE_CONSTANT_IN_NAMESPACE;

tests/CSharp/CSharp.Tests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void TestUncompilableCode()
2323
#pragma warning disable 0219 // warning CS0219: The variable `foo' is assigned but its value is never used
2424

2525
ALLCAPS_UNDERSCORES a;
26+
new MultipleInheritance().Dispose();
2627
using (var testRenaming = new TestRenaming())
2728
{
2829
testRenaming.name();

tests/CSharp/CSharp.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -839,36 +839,6 @@ HasVirtualDtor1* CallDtorVirtually::getHasVirtualDtor1(HasVirtualDtor1* returned
839839
return returned;
840840
}
841841

842-
void SecondaryBase::VirtualMember()
843-
{
844-
}
845-
846-
int SecondaryBase::property()
847-
{
848-
return 0;
849-
}
850-
851-
void SecondaryBase::setProperty(int value)
852-
{
853-
}
854-
855-
void SecondaryBase::function(bool* ok)
856-
{
857-
}
858-
859-
void SecondaryBase::protectedFunction()
860-
{
861-
}
862-
863-
int SecondaryBase::protectedProperty()
864-
{
865-
return 0;
866-
}
867-
868-
void SecondaryBase::setProtectedProperty(int value)
869-
{
870-
}
871-
872842
TestOverrideFromSecondaryBase::TestOverrideFromSecondaryBase()
873843
{
874844
}

tests/CSharp/CSharp.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -684,32 +684,6 @@ class HasProtectedNestedAnonymousType
684684
} u;
685685
};
686686

687-
class DLL_API SecondaryBase
688-
{
689-
public:
690-
enum Property
691-
{
692-
P1,
693-
P2
694-
};
695-
enum Function
696-
{
697-
M1,
698-
M2
699-
};
700-
701-
virtual void VirtualMember();
702-
int property();
703-
void setProperty(int value);
704-
void function(bool* ok = 0);
705-
typedef void HasPointerToEnum(Property* pointerToEnum);
706-
HasPointerToEnum* hasPointerToEnum;
707-
protected:
708-
void protectedFunction();
709-
int protectedProperty();
710-
void setProtectedProperty(int value);
711-
};
712-
713687
class DLL_API TestOverrideFromSecondaryBase : public Foo, public SecondaryBase
714688
{
715689
public:

0 commit comments

Comments
 (0)