Skip to content

Commit 43c17f9

Browse files
committed
Generate valid C# for r-values to void pointers
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent d24ef35 commit 43c17f9

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

src/Generator/Generators/CSharp/CSharpMarshal.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
556556
Context.ArgumentPrefix.Write("&");
557557

558558
bool isVoid = primitive == PrimitiveType.Void &&
559-
pointee.IsAddress() && pointer.IsReference();
559+
pointee.IsAddress() && pointer.IsReference() &&
560+
pointer.GetFinalQualifiedPointee().Qualifiers.IsConst;
560561
if (pointer.Pointee.Desugar(false) is TemplateParameterSubstitutionType ||
561562
isVoid)
562563
{

tests/CSharp/CSharp.Tests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void TestUncompilableCode()
9595
}
9696

9797
CSharp.CSharp.ReturnCharPointer();
98+
CSharp.CSharp.RValueReferenceToPointer(null);
9899

99100
#pragma warning restore 0168
100101
#pragma warning restore 0219

tests/CSharp/CSharp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,10 @@ const char*& takeConstCharStarRef(const char*& c)
15651565
return c;
15661566
}
15671567

1568+
void rValueReferenceToPointer(void*&& v)
1569+
{
1570+
}
1571+
15681572
boolean_t takeTypemapTypedefParam(boolean_t b)
15691573
{
15701574
return b;

tests/CSharp/CSharp.h

+1
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,7 @@ class DLL_API HasFunctionPtrField
13071307
DLL_API void va_listFunction(va_list v);
13081308
DLL_API char* returnCharPointer();
13091309
DLL_API const char*& takeConstCharStarRef(const char*& c);
1310+
DLL_API void rValueReferenceToPointer(void*&& v);
13101311

13111312
struct {
13121313
struct {

0 commit comments

Comments
 (0)