diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-stmt.cpp | 10 | ||||
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 1 |
2 files changed, 11 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) diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index fed4944d3..4a9b83c6c 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -278,6 +278,7 @@ DIAGNOSTIC(30054, Error, targetLabelDoesNotMarkBreakableStmt, "invalid break tar DIAGNOSTIC(30055, Error, useOfNonShortCircuitingOperatorInDiffFunc, "non-short-circuiting `?:` operator is not allowed in a differentiable function, use `select` instead.") DIAGNOSTIC(30056, Warning, useOfNonShortCircuitingOperator, "non-short-circuiting `?:` operator is deprecated, use 'select' instead.") DIAGNOSTIC(30057, Error, assignmentInPredicateExpr, "use an assignment operation as predicate expression is not allowed, wrap the assignment with '()' to clarify the intent.") +DIAGNOSTIC(30058, Warning, danglingEqualityExpr, "result of '==' not used, did you intend '='?") DIAGNOSTIC(30043, Error, getStringHashRequiresStringLiteral, "getStringHash parameter can only accept a string literal") |
