[Issue 23520] pragma(inline, false) not applied to nested function declaration
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 1 13:41:22 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23520
--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject.org> ---
(In reply to RazvanN from comment #3)
> That is true, but in your original bug report you want to apply the pragma
> to the declarations inside the body, right? To be able to do that you need
> to create a PragmaDeclaration and attach it to the the scope of the pragma
> statement body (struct Scope has a field inlining of type PragmaDeclaration).
Yes, that can be handled by the statement semantic for PragmaStatement.
I think something like the following should suffice:
---
Scope* sc2 = sc;
scope(exit)
if (sc2 != sc)
sc2.pop();
// ...
if (ps.ident == Id.Pinline)
{
if (auto fd = sc.func)
{
if (ps._body)
sc2 = new PragmaDeclaration(...).newScope(sc);
else
fd.inlining = evalPragmaInline(ps.loc, sc, ps.args);
}
else
{
ps.error("`pragma(inline)` is not inside a function");
return setError();
}
}
// ...
if (ps._body)
{
ps._body = ps._body.statementSemantic(sc2);
}
--
More information about the Digitalmars-d-bugs
mailing list