Skip to content

Commit 24b64d4

Browse files
authored
Merge pull request #2875 from thewilsonator/pragma-mangle-aggregate
Allow `pragma(mangle,...)` on an aggregate
2 parents 6254a91 + 26dd744 commit 24b64d4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

spec/pragma.dd

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ $(H3 $(LNAME2 mangle, $(D pragma mangle)))
272272

273273
$(P Overrides the default mangling for a symbol.)
274274

275-
$(P There must be one $(ASSIGNEXPRESSION) and it must evaluate at compile time to a string literal.
275+
$(P For variables and functions there must be one $(ASSIGNEXPRESSION) and it must evaluate at compile time to a string literal.
276+
For aggregates there may be one or two $(ASSIGNEXPRESSION)s, one of which must evaluate at compile time to a string literal and
277+
one which must evaluate to a symbol. If that symbol is a $(I TemplateInstance), the aggregate is treated as a template
278+
that has the signature and arguments of the $(I TemplateInstance). The identifier of the symbol is used when no string is supplied.
279+
Both arguments may be used used when an aggregate's name is a D keyword.
276280
)
277281

278282
$(P It only applies to function and variable symbols. Other symbols are ignored.)
@@ -291,6 +295,18 @@ $(H3 $(LNAME2 mangle, $(D pragma mangle)))
291295
---
292296
pragma(mangle, "body")
293297
extern(C) void body_func();
298+
pragma(mangle, "function")
299+
extern(C++) struct _function {}
300+
template ScopeClass(C)
301+
{
302+
pragma(mangle, C.stringof, C)
303+
struct ScopeClass { char[__traits(classInstanceSize, C)] buffer; }
304+
}
305+
extern(C++)
306+
{
307+
class MyClassA(T) {}
308+
void func(ref ScopeClass!(MyClassA!int)); // mangles as MyClass<int>&
309+
}
294310
---
295311
)
296312

0 commit comments

Comments
 (0)