Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 12, 2023 [Issue 24276] ImportC: typedef aliases not emitted correctly in .di files | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24276 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #1 from Walter Bright <bugzilla@digitalmars.com> --- This is coming from this line in the C parser: if (isalias) { auto ad = new AST.AliasDeclaration(token.loc, id, dt); ad.adFlags |= ad.hidden; // do not print when generating .di files s = ad; } https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cparse.d#L1937 -- |
December 12, 2023 [Issue 24276] ImportC: typedef aliases not emitted correctly in .di files | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24276 --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> --- Simplifying: typedef union S { int x; } S; typedef S T; Produces the .di file: // D import file generated from 'test.i' extern (C) { union S { int x = void; } union S; alias T = S; // this line is missing } I can fix it to emit the missing `alias T` line. But getting rid of the extra `union S;` is a problem. The trouble is, the .di file is generated before the symbol table is built, and so doesn't know about the collision. D and C have different semantics (in C you can redeclare a tag name as many times as you want, but not in D). A .di file is compiled as a D file, not a C. The impedance mismatch between C and D is taken care of in the semantic routines, but the .di file has not undergone semantic analysis. This looks like this will be one of those cases where human tweaking of the .di file or the C file will be needed. Either delete the `union S;` from the .di file, or remove the first typedef, or don't name the typedef the same as the tag name. In general, C=>D translation problems are inevitable when using a C symbol with the same name as a C tag symbol. These problems exist for every source translation program, which is why ImportC is a compiler not a translator, and why importing the C code works fine, as you reported. -- |
December 12, 2023 [Issue 24276] ImportC: typedef aliases not emitted correctly in .di files | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24276 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Hardware|x86 |All OS|Mac OS X |All -- |
December 12, 2023 [Issue 24276] ImportC: typedef aliases not emitted correctly in .di files | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24276 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> --- @WalterBright created dlang/dmd pull request #15899 "fix Issue 24276 - ImportC: typedef aliases not emitted correctly in .…" fixing this issue: - fix Issue 24276 - ImportC: typedef aliases not emitted correctly in .di files https://github.com/dlang/dmd/pull/15899 -- |
December 12, 2023 [Issue 24276] ImportC: typedef aliases not emitted correctly in .di files | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24276 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/dmd pull request #15899 "fix Issue 24276 - ImportC: typedef aliases not emitted correctly in .…" was merged into master: - 0cc531948c80af3afcab95f7edf397651592ad40 by Walter Bright: fix Issue 24276 - ImportC: typedef aliases not emitted correctly in .di files https://github.com/dlang/dmd/pull/15899 -- |
Copyright © 1999-2021 by the D Language Foundation