diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-inheritance.cpp | 14 | ||||
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/slang-check-inheritance.cpp b/source/slang/slang-check-inheritance.cpp index 5fff47cf1..18624424c 100644 --- a/source/slang/slang-check-inheritance.cpp +++ b/source/slang/slang-check-inheritance.cpp @@ -569,6 +569,18 @@ namespace Slang // later. } + // If we still cannot find a facet, then there is a true cycle in + // the inheritance graph, which is an error in the user code. + if (!foundFacet.getImpl()) + { + if (!bases.isEmpty()) + { + auto baseDecl = (*bases.begin())->facetImpl.origin.declRef.getDecl(); + getSink()->diagnose(baseDecl, Diagnostics::cyclicReferenceInInheritance, baseDecl); + } + return; + } + // At this point we definitely have a facet we'd like to // add to the output, whether it was found via the true // C3 approach, or our relaxed rule above. @@ -793,6 +805,8 @@ namespace Slang { for (auto base : *this) { + if (base->facets.isEmpty()) + continue; if (base->facets.getTail().containsMatchFor(facet)) return true; } diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 7a72daa5e..6299d6666 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -470,6 +470,8 @@ DIAGNOSTIC(30510, Error, loopInDiffFuncRequireUnrollOrMaxIters, "loops inside a // TODO: need to assign numbers to all these extra diagnostics... DIAGNOSTIC(39999, Fatal, cyclicReference, "cyclic reference '$0'.") +DIAGNOSTIC(39999, Error, cyclicReferenceInInheritance, "cyclic reference in inheritance graph '$0'.") + DIAGNOSTIC(39999, Error, localVariableUsedBeforeDeclared, "local variable '$0' is being used before its declaration.") DIAGNOSTIC(39999, Error, variableUsedInItsOwnDefinition, "the initial-value expression for variable '$0' depends on the value of the variable itself") DIAGNOSTIC(39901, Fatal , cannotProcessInclude, "internal compiler error: cannot process '__include' in the current semantic checking context.") |
