dmd
dmd copied to clipboard
[dtoh] ensure class return types are fwd declared
Thanks for your pull request and interest in making D better, @thewilsonator! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:andReturns:)
Please see CONTRIBUTING.md for more information.
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.
Bugzilla references
Your PR doesn't reference any Bugzilla issue.
If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub run digger -- build "master + dmd#16003"
+5,406 −5,490
Looks like it did something, exactly what Im not quite sure.
Again, the header was invalid before, this is not "more invalid", it is less invalid than before. To be sure, it is definitely still very invalid, but this is an improvement as now:
extern(C++):
Class foo() { return new Class(); }
class Class {}
works as it will now correctly generate a forward declaration
class Class;
Class* foo();
class Class {}
previously it would not
This is really only a 2 line change, the rest is the changed frontend.h.
Since I'm not a user of frontend.h, but @ibuclaw is, I will defer to him.
@thewilsonator Is there any way we can, at least, partially test the output of dtoh with some real life tests? The entire point of dtoh was to replace the C++ headers present in the dmd tree, but now we're stuck with both the headers and a semi-working dtoh.
Also, you mention about existing bugs. Are these documented anywhere? We should probably work in a more systematic way so that we eventually get rid of the manually maintained headers.
Is there any way we can, at least, partially test the output of dtoh with some real life tests?
There are some dtoh tests under compilable/ but they are... not comprehensive.
The entire point of dtoh was to replace the C++ headers present in the dmd tree, but now we're stuck with both the headers and a semi-working dtoh.
indeed.
Are these [bugs] documented anywhere?
Not that I'm aware of. But if you want to find them just do
#include "frontend.h"
By far the largest source of errors is failing to emit a full declaration of base class before emitting a subclass such that a class tries to inherit from something that is not (yet) defined. Wouldn't be surprised if (sub)classes + namespaces in combination also don't work, but thankfully we don't need to worry about those for DMD.