Skip to content

Commit 7ca01e6

Browse files
committed
Merge remote-tracking branch 'upstream/stable'
2 parents 47d34a4 + 791f90d commit 7ca01e6

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.087.0
1+
v2.087.1-beta.1

src/dmd/cppmangle.d

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,24 @@ private final class CppMangleVisitor : Visitor
236236
}
237237
}
238238

239-
bool substitute(RootObject p)
239+
/**
240+
* Attempt to perform substitution on `p`
241+
*
242+
* If `p` already appeared in the mangling, it is stored as
243+
* a 'part', and short references in the form of `SX_` can be used.
244+
* Note that `p` can be anything: template declaration, struct declaration,
245+
* class declaration, namespace...
246+
*
247+
* Params:
248+
* p = The object to attempt to substitute
249+
* nested = Whether or not `p` is to be considered nested.
250+
* When `true`, `N` will be prepended before the substitution.
251+
*
252+
* Returns:
253+
* Whether `p` already appeared in the mangling,
254+
* and substitution has been written to `this.buf`.
255+
*/
256+
bool substitute(RootObject p, bool nested = false)
240257
{
241258
//printf("substitute %s\n", p ? p.toChars() : null);
242259
auto i = find(p);
@@ -245,6 +262,8 @@ private final class CppMangleVisitor : Visitor
245262
//printf("\tmatch\n");
246263
/* Sequence is S_, S0_, .., S9_, SA_, ..., SZ_, S10_, ...
247264
*/
265+
if (nested)
266+
buf.writeByte('N');
248267
buf.writeByte('S');
249268
writeSequenceFromIndex(i);
250269
buf.writeByte('_');
@@ -550,19 +569,24 @@ private final class CppMangleVisitor : Visitor
550569
if (TemplateInstance ti = s.isTemplateInstance())
551570
{
552571
bool needsTa = false;
553-
if (substitute(ti.tempdecl))
572+
const isNested = !!ti.tempdecl.namespace || !!getQualifier(ti.tempdecl);
573+
if (substitute(ti.tempdecl, !haveNE && isNested))
574+
{
554575
template_args(ti);
576+
if (!haveNE && isNested)
577+
buf.writeByte('E');
578+
}
555579
else if (this.writeStdSubstitution(ti, needsTa))
556580
{
557581
if (needsTa)
558582
template_args(ti);
559583
}
560584
else
561585
{
562-
append(ti.tempdecl);
563586
this.writeNamespace(
564587
s.namespace, () {
565588
this.writeIdentifier(ti.tempdecl.toAlias().ident);
589+
append(ti.tempdecl);
566590
template_args(ti);
567591
}, haveNE);
568592
}
@@ -811,7 +835,6 @@ private final class CppMangleVisitor : Visitor
811835
isChar((*ti.tiargs)[0]) &&
812836
isChar_traits_char((*ti.tiargs)[1]) &&
813837
isAllocator_char((*ti.tiargs)[2]))
814-
815838
{
816839
buf.writestring("Ss");
817840
return;

test/compilable/cppmangle.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,3 +1155,16 @@ version (Posix)
11551155
static assert(fun20022_5.mangleof == `_ZN7ns2002210fun20022_5ENS_11Enum20022_1E`);
11561156
static assert(fun20022_6.mangleof == `_ZN7ns2002210fun20022_6ENS_11Enum20022_2E`);
11571157
}
1158+
1159+
// https://issues.dlang.org/show_bug.cgi?id=20094
1160+
version (Posix)
1161+
{
1162+
extern(C++, "ns20094")
1163+
{
1164+
struct xvector20094 (T) {}
1165+
alias V20094 = xvector20094!(ubyte);
1166+
}
1167+
1168+
extern(C++) void test20094(xvector20094!(V20094)* v);
1169+
static assert(test20094.mangleof == `_Z9test20094PN7ns2009412xvector20094INS0_IhEEEE`);
1170+
}

0 commit comments

Comments
 (0)