diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-05 13:37:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-05 13:37:22 -0700 |
| commit | c9eb594cefa0659639aae641dc6847c92196dc89 (patch) | |
| tree | 9495dce0aa30f83a4e7eeb4605871f8e40e5f26f /source/slang/slang-check-stmt.cpp | |
| parent | dc45802707b6e3f1a3eedc8e8a5583102b2d8a0d (diff) | |
Warn on dangling comparison operator. (#2779)
Fixes #1685
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-stmt.cpp')
| -rw-r--r-- | source/slang/slang-check-stmt.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-check-stmt.cpp b/source/slang/slang-check-stmt.cpp index a61f48af6..6efc3e52e 100644 --- a/source/slang/slang-check-stmt.cpp +++ b/source/slang/slang-check-stmt.cpp @@ -339,6 +339,16 @@ namespace Slang void SemanticsStmtVisitor::visitExpressionStmt(ExpressionStmt *stmt) { stmt->expression = CheckExpr(stmt->expression); + if (auto operatorExpr = as<OperatorExpr>(stmt->expression)) + { + if (auto func = as<VarExpr>(operatorExpr->functionExpr)) + { + if (func->name && func->name->text == "==") + { + getSink()->diagnose(operatorExpr, Diagnostics::danglingEqualityExpr); + } + } + } } void SemanticsStmtVisitor::tryInferLoopMaxIterations(ForStmt* stmt) |
