summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp83
1 files changed, 43 insertions, 40 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index 5141d8634..bc5d144b0 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -6798,50 +6798,55 @@ namespace Slang
}
entryPoint->genericParameterTypes.Add(type);
}
- // check that user-provioded type arguments conforms to the generic type
- // parameter declaration of this translation unit
-
- // collect global generic parameters from all imported modules
- List<RefPtr<GlobalGenericParamDecl>> globalGenericParams;
- // add current translation unit first
- {
- auto globalGenParams = translationUnit->SyntaxNode->getMembersOfType<GlobalGenericParamDecl>();
- for (auto p : globalGenParams)
- globalGenericParams.Add(p);
- }
- // add imported modules
- for (auto loadedModule : entryPoint->compileRequest->loadedModulesList)
- {
- auto moduleDecl = loadedModule->moduleDecl;
- auto globalGenParams = moduleDecl->getMembersOfType<GlobalGenericParamDecl>();
- for (auto p : globalGenParams)
- globalGenericParams.Add(p);
- }
- if (globalGenericParams.Count() != entryPoint->genericParameterTypes.Count())
+
+ // validate global type arguments only when we are generating code
+ if ((entryPoint->compileRequest->compileFlags & SLANG_COMPILE_FLAG_NO_CODEGEN) == 0)
{
- sink->diagnose(entryPoint->decl, Diagnostics::mismatchEntryPointTypeArgument, globalGenericParams.Count(),
+ // check that user-provioded type arguments conforms to the generic type
+ // parameter declaration of this translation unit
+
+ // collect global generic parameters from all imported modules
+ List<RefPtr<GlobalGenericParamDecl>> globalGenericParams;
+ // add current translation unit first
+ {
+ auto globalGenParams = translationUnit->SyntaxNode->getMembersOfType<GlobalGenericParamDecl>();
+ for (auto p : globalGenParams)
+ globalGenericParams.Add(p);
+ }
+ // add imported modules
+ for (auto loadedModule : entryPoint->compileRequest->loadedModulesList)
+ {
+ auto moduleDecl = loadedModule->moduleDecl;
+ auto globalGenParams = moduleDecl->getMembersOfType<GlobalGenericParamDecl>();
+ for (auto p : globalGenParams)
+ globalGenericParams.Add(p);
+ }
+ if (globalGenericParams.Count() != entryPoint->genericParameterTypes.Count())
+ {
+ sink->diagnose(entryPoint->decl, Diagnostics::mismatchEntryPointTypeArgument, globalGenericParams.Count(),
entryPoint->genericParameterTypes.Count());
- return;
- }
- // if number of entry-point type arguments matches parameters, try find
- // SubtypeWitness for each argument
- int index = 0;
- for (auto & gParam : globalGenericParams)
- {
- for (auto constraint : gParam->getMembersOfType<GenericTypeConstraintDecl>())
+ return;
+ }
+ // if number of entry-point type arguments matches parameters, try find
+ // SubtypeWitness for each argument
+ int index = 0;
+ for (auto & gParam : globalGenericParams)
{
- auto interfaceType = GetSup(DeclRef<GenericTypeConstraintDecl>(constraint, nullptr));
- SemanticsVisitor visitor(sink, entryPoint->compileRequest, translationUnit);
- auto witness = visitor.tryGetSubtypeWitness(entryPoint->genericParameterTypes[index], interfaceType);
- if (!witness)
+ for (auto constraint : gParam->getMembersOfType<GenericTypeConstraintDecl>())
{
- sink->diagnose(gParam,
- Diagnostics::typeArgumentDoesNotConformToInterface, gParam->nameAndLoc.name, entryPoint->genericParameterTypes[index],
- interfaceType);
+ auto interfaceType = GetSup(DeclRef<GenericTypeConstraintDecl>(constraint, nullptr));
+ SemanticsVisitor visitor(sink, entryPoint->compileRequest, translationUnit);
+ auto witness = visitor.tryGetSubtypeWitness(entryPoint->genericParameterTypes[index], interfaceType);
+ if (!witness)
+ {
+ sink->diagnose(gParam,
+ Diagnostics::typeArgumentDoesNotConformToInterface, gParam->nameAndLoc.name, entryPoint->genericParameterTypes[index],
+ interfaceType);
+ }
+ entryPoint->genericParameterWitnesses.Add(witness);
}
- entryPoint->genericParameterWitnesses.Add(witness);
+ index++;
}
- index++;
}
if (sink->errorCount != 0)
return;
@@ -6851,8 +6856,6 @@ namespace Slang
// if they are of types that are appropriate to the stage, etc.
}
-
-
void checkTranslationUnit(
TranslationUnitRequest* translationUnit)
{