Skip to content

Commit

Permalink
fix Issue 23974 - A ModuleInfo in a separate Windows DLL should not b…
Browse files Browse the repository at this point in the history
…e referred to by MIimportedModules
  • Loading branch information
WalterBright committed Jan 16, 2024
1 parent 1955596 commit 1b6232e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions compiler/src/dmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ extern (C++) final class Module : Package
FileType filetype; // source file type
bool hasAlwaysInlines; // contains references to functions that must be inlined
bool isPackageFile; // if it is a package.d
bool isImportedModule; // module contains exported declarations, meaning it is an interface to a DLL
Package pkg; // if isPackageFile is true, the Package that contains this package.d
Strings contentImportedFiles; // array of files whose content was imported
int needmoduleinfo;
Expand Down
14 changes: 14 additions & 0 deletions compiler/src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (ad)
dsym.storage_class |= ad.storage_class & STC.TYPECTOR;

if (dsym.isImportedSymbol())
{
/* A module with imported symbols is an imported module
*/
sc._module.isImportedModule = true;
}

/* If auto type inference, do the inference
*/
int inferred = 0;
Expand Down Expand Up @@ -3676,6 +3683,13 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (funcdecl.isAbstract() && funcdecl.isFinalFunc())
.error(funcdecl.loc, "%s `%s` cannot be both `final` and `abstract`", funcdecl.kind, funcdecl.toPrettyChars);

if (funcdecl.isImportedSymbol())
{
/* A module with imported symbols is an imported module
*/
sc._module.isImportedModule = true;
}

if (funcdecl.printf || funcdecl.scanf)
{
checkPrintfScanfSignature(funcdecl, f, sc);
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -7163,6 +7163,7 @@ class Module final : public Package
FileType filetype;
bool hasAlwaysInlines;
bool isPackageFile;
bool isImportedModule;
Package* pkg;
Array<const char* > contentImportedFiles;
int32_t needmoduleinfo;
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Module final : public Package
FileType filetype; // source file type
d_bool hasAlwaysInlines; // contains references to functions that must be inlined
d_bool isPackageFile; // if it is a package.d
d_bool isImportedModule; // module contains exported declarations, meaning it is an interface to a DLL
Package *pkg; // if isPackageFile is true, the Package that contains this package.d
Strings contentImportedFiles; // array of files whose content was imported
int needmoduleinfo;
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/toobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void genModuleInfo(Module m)
for (size_t i = 0; i < m.aimports.length; i++)
{
Module mod = m.aimports[i];
if (!mod.needmoduleinfo)
if (!mod.needmoduleinfo || mod.isImportedModule)
aimports_dim--;
}

Expand Down Expand Up @@ -174,7 +174,7 @@ void genModuleInfo(Module m)
{
Module mod = m.aimports[i];

if (!mod.needmoduleinfo)
if (!mod.needmoduleinfo || mod.isImportedModule)
continue;

Symbol *s = toSymbol(mod);
Expand Down

0 comments on commit 1b6232e

Please sign in to comment.