Skip to content

Commit

Permalink
make deinitializeDMD reset onlyOneMain check
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Nov 22, 2024
1 parent 3fa3ac8 commit cc0c0b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/src/dmd/frontend.d
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,13 @@ void deinitializeDMD()
import dmd.objc : Objc;
import dmd.target : target;
import dmd.errors : diagnostics;
import dmd.glue : resetLastMain;

diagnosticHandler = null;
fatalErrorHandler = null;

global.deinitialize();
resetLastMain();

Type.deinitialize();
Id.deinitialize();
Expand Down
8 changes: 7 additions & 1 deletion compiler/src/dmd/glue.d
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,11 @@ void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj)
}
}

void resetLastMain()
{
lastMain = null;

Check warning on line 1071 in compiler/src/dmd/glue.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/glue.d#L1071

Added line #L1071 was not covered by tests
}

private:

alias symbols = Array!(Symbol*);
Expand Down Expand Up @@ -1623,6 +1628,8 @@ private bool entryPointFunctions(Obj objmod, FuncDeclaration fd)
return false;
}

private __gshared FuncDeclaration lastMain;

/****************************************
* Only one entry point function is allowed. Print error if more than one.
* Params:
Expand All @@ -1632,7 +1639,6 @@ private bool entryPointFunctions(Obj objmod, FuncDeclaration fd)
*/
private bool onlyOneMain(FuncDeclaration fd)
{
__gshared FuncDeclaration lastMain;
if (lastMain)
{
const format = (target.os == Target.OS.Windows)
Expand Down

0 comments on commit cc0c0b1

Please sign in to comment.