From e08f0c6ea0552a2d626294c718cd4409f437ba10 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 12 Mar 2018 14:02:28 -0400 Subject: Stop compilation when a imported module contains errors. (#440) * Stop compilation when a important module contains errors. * Fixup test cases --- source/slang/slang.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index f2e5587fa..1d888dcb5 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -526,9 +526,9 @@ void CompileRequest::loadParsedModule( { // If we didn't run into any errors, then try to generate // IR code for the imported module. + SLANG_ASSERT(errorCountAfter == 0); loadedModule->irModule = generateIRForTranslationUnit(translationUnit); } - loadedModulesList.Add(loadedModule); } @@ -536,7 +536,7 @@ RefPtr CompileRequest::loadModule( Name* name, String const& path, String const& source, - SourceLoc const&) + SourceLoc const& srcLoc) { RefPtr translationUnit = new TranslationUnitRequest(); translationUnit->compileRequest = this; @@ -559,6 +559,7 @@ RefPtr CompileRequest::loadModule( if( errorCountAfter != errorCountBefore ) { + mSink.diagnose(srcLoc, Diagnostics::errorInImportedModule); // Something went wrong during the parsing, so we should bail out. return nullptr; } @@ -568,6 +569,15 @@ RefPtr CompileRequest::loadModule( name, path); + errorCountAfter = mSink.GetErrorCount(); + + if (errorCountAfter != errorCountBefore) + { + mSink.diagnose(srcLoc, Diagnostics::errorInImportedModule); + // Something went wrong during the parsing, so we should bail out. + return nullptr; + } + return translationUnit->SyntaxNode; } -- cgit v1.2.3