summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rwxr-xr-xsource/slang/slang-compiler.h16
-rw-r--r--source/slang/slang-diagnostic-defs.h3
-rw-r--r--source/slang/slang.cpp17
3 files changed, 29 insertions, 7 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index 0742859f1..0ee63fd09 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -1519,10 +1519,14 @@ namespace Slang
{
public:
ModuleBeingImportedRAII(
- Linkage* linkage,
- Module* module)
+ Linkage* linkage,
+ Module* module,
+ Name* name,
+ SourceLoc const& importLoc)
: linkage(linkage)
, module(module)
+ , name(name)
+ , importLoc(importLoc)
{
next = linkage->m_modulesBeingImported;
linkage->m_modulesBeingImported = this;
@@ -1535,15 +1539,21 @@ namespace Slang
Linkage* linkage;
Module* module;
+ Name* name;
+ SourceLoc importLoc;
ModuleBeingImportedRAII* next;
};
// Any modules currently being imported will be listed here
- ModuleBeingImportedRAII* m_modulesBeingImported = nullptr;
+ ModuleBeingImportedRAII*m_modulesBeingImported = nullptr;
/// Is the given module in the middle of being imported?
bool isBeingImported(Module* module);
+ /// Diagnose that an error occured in the process of importing a module
+ void _diagnoseErrorInImportedModule(
+ DiagnosticSink* sink);
+
List<Type*> m_specializedTypes;
};
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 4c10ff5d5..8f94c47af 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -433,7 +433,8 @@ DIAGNOSTIC(38027, Error, mismatchExistentialSlotArgCount, "expected $0 existenti
DIAGNOSTIC(38029, Error,typeArgumentDoesNotConformToInterface, "type argument '$0' does not conform to the required interface '$1'")
DIAGNOSTIC(38200, Error, recursiveModuleImport, "module `$0` recursively imports itself")
-DIAGNOSTIC(39999, Fatal, errorInImportedModule, "error in imported module, compilation ceased.")
+DIAGNOSTIC(39999, Error, errorInImportedModule, "import of module '$0' failed because of a compilation error")
+DIAGNOSTIC(39999, Fatal, complationCeased, "compilation ceased")
// 39xxx - Type layout and parameter binding.
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 9d2d766b9..f8af39fcb 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -2397,6 +2397,15 @@ Module* Linkage::loadModule(String const& name)
sink);
}
+void Linkage::_diagnoseErrorInImportedModule(
+ DiagnosticSink* sink)
+{
+ for(auto info = m_modulesBeingImported; info; info = info->next)
+ {
+ sink->diagnose(info->importLoc, Diagnostics::errorInImportedModule, info->name);
+ }
+ sink->diagnose(SourceLoc(), Diagnostics::complationCeased);
+}
RefPtr<Module> Linkage::loadModule(
Name* name,
@@ -2418,7 +2427,9 @@ RefPtr<Module> Linkage::loadModule(
ModuleBeingImportedRAII moduleBeingImported(
this,
- module);
+ module,
+ name,
+ srcLoc);
// Create with the 'friendly' name
SourceFile* sourceFile = getSourceManager()->createSourceFileWithBlob(filePathInfo, sourceBlob);
@@ -2431,7 +2442,7 @@ RefPtr<Module> Linkage::loadModule(
if( errorCountAfter != errorCountBefore )
{
- sink->diagnose(srcLoc, Diagnostics::errorInImportedModule);
+ _diagnoseErrorInImportedModule(sink);
}
if (errorCountAfter)
{
@@ -2449,7 +2460,7 @@ RefPtr<Module> Linkage::loadModule(
if (errorCountAfter != errorCountBefore)
{
- sink->diagnose(srcLoc, Diagnostics::errorInImportedModule);
+ _diagnoseErrorInImportedModule(sink);
// Something went wrong during the parsing, so we should bail out.
return nullptr;
}