From 0af4d5db42558ca09494f597e5dc0c53f24539d8 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 31 Dec 2017 02:35:01 +0100 Subject: [PATCH] Upstream GDC patch to mangle va_list as a pointer. The default behaviour is to raise an internal compiler error and exit if cppmangle encounters a static array parameter. This is not compatible with how GDC represents va_lists internally. In the codegen pass, GDC will saturate a va_list to a pointer if its underlying type is a static array. --- src/dmd/cppmangle.d | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/dmd/cppmangle.d b/src/dmd/cppmangle.d index 2dc635e128ad..f29d4e95feaa 100644 --- a/src/dmd/cppmangle.d +++ b/src/dmd/cppmangle.d @@ -657,6 +657,19 @@ private final class CppMangleVisitor : Visitor td = new TypeDelegate(td); t = merge(t); } + static if (IN_GCC) + { + // Could be a va_list, which we mangle as a pointer. + if (t.ty == Tsarray && Type.tvalist.ty == Tsarray) + { + Type tb = t.toBasetype().mutableOf(); + if (tb == Type.tvalist) + { + tb = t.nextOf().pointerTo(); + t = tb.castMod(t.mod); + } + } + } if (t.ty == Tsarray) { // Static arrays in D are passed by value; no counterpart in C++