Bug 20700 – Forward references leads to `extern(C++, class|struct)` being ignored

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2020-03-26T08:46:41Z
Last change time
2020-04-03T07:06:32Z
Keywords
C++, industry, pull
Assigned to
No Owner
Creator
Mathias LANG

Comments

Comment #0 by pro.mathias.lang — 2020-03-26T08:46:41Z
Consider the following code, compiled with DMD 2.091.0 on Windows x64: ``` extern(C++): version(Bad) void before(const ref Foo); extern(C++, class) struct Foo {} void after(const ref Foo); version(Bad) pragma(msg, "Before: ", before.mangleof); pragma(msg, "After: ", after.mangleof); ``` With no version, it outputs: ?after@@YAXABVFoo@@@Z Which is the correct mangling. However with `-version=Bad`: ``` Before: ?before@@YAXABUFoo@@@Z After: ?after@@YAXABUFoo@@@Z ```
Comment #1 by dlang-bot — 2020-03-31T03:39:42Z
@Geod24 created dlang/dmd pull request #10988 "[stable] Fix issue 20700 - Forward references leads to extern(C++, class|struct) being ignored" fixing this issue: - Fix issue 20700 - Forward references leads to extern(C++, class|struct) being ignored On the long run, it looks like we should just move the setScope to AttribDeclaration, but this is a simple bugfix to target stable. https://github.com/dlang/dmd/pull/10988
Comment #2 by dlang-bot — 2020-04-03T07:06:32Z
dlang/dmd pull request #10988 "[stable] Fix issue 20700 - Forward references leads to extern(C++, class|struct) being ignored" was merged into stable: - 050e71dfeaa6f1bfd75845ee8baacf1940146e27 by Geod24: Fix issue 20700 - Fwd refs leads to extern(C++, class|struct) being ignored `Type`-derived AST nodes do not support the same kind of semantic analysis that `Dsymbol`-derived one do. The issue was that in some codes, semantic analysis on the type was performed before it was performed on the declaration, and chasing those cases turned out to be endless, hence the minor refactoring. https://github.com/dlang/dmd/pull/10988