diff options
| author | Yong He <yonghe@outlook.com> | 2018-03-12 14:02:28 -0400 |
|---|---|---|
| committer | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-03-12 11:02:28 -0700 |
| commit | e08f0c6ea0552a2d626294c718cd4409f437ba10 (patch) | |
| tree | eea41576e8422bf9e299227328b5e326ce90dafd /source | |
| parent | 51bc468959b5ab8103c196adaabcafdb5d0b3feb (diff) | |
Stop compilation when a imported module contains errors. (#440)
* Stop compilation when a important module contains errors.
* Fixup test cases
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/diagnostic-defs.h | 1 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/source/slang/diagnostic-defs.h b/source/slang/diagnostic-defs.h index 14efdb9a9..220ad44ff 100644 --- a/source/slang/diagnostic-defs.h +++ b/source/slang/diagnostic-defs.h @@ -273,6 +273,7 @@ DIAGNOSTIC(38020, Error, mismatchEntryPointTypeArgument, "expecting $0 entry-poi DIAGNOSTIC(38021, Error, typeArgumentDoesNotConformToInterface, "type argument `$1` for generic parameter `$0` does not conform to interface `$1`.") DIAGNOSTIC(38200, Error, recursiveModuleImport, "module `$0` recursively imports itself") +DIAGNOSTIC(39999, Fatal, errorInImportedModule, "error in imported module, compilation ceased.") // // 4xxxx - IL code generation. 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<ModuleDecl> CompileRequest::loadModule( Name* name, String const& path, String const& source, - SourceLoc const&) + SourceLoc const& srcLoc) { RefPtr<TranslationUnitRequest> translationUnit = new TranslationUnitRequest(); translationUnit->compileRequest = this; @@ -559,6 +559,7 @@ RefPtr<ModuleDecl> 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<ModuleDecl> 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; } |
