| 1300 | ////////////////////////////////////////////////////////////////////////// |
| 1301 | |
| 1302 | bool BfExpression::VerifyIsStatement(BfPassInstance* passInstance, bool ignoreError) |
| 1303 | { |
| 1304 | if (auto attribExpr = BfNodeDynCast<BfAttributedExpression>(this)) |
| 1305 | { |
| 1306 | return attribExpr->mExpression->VerifyIsStatement(passInstance, ignoreError); |
| 1307 | } |
| 1308 | |
| 1309 | if ((!BfNodeIsExact<BfAssignmentExpression>(this)) && |
| 1310 | (!BfNodeIsExact<BfInvocationExpression>(this)) && |
| 1311 | (!BfNodeIsExact<BfObjectCreateExpression>(this))) |
| 1312 | { |
| 1313 | if (auto castExpr = BfNodeDynCast<BfCastExpression>(this)) |
| 1314 | { |
| 1315 | if ((castExpr->mTypeRef != NULL) && (castExpr->mTypeRef->ToString() == "void")) |
| 1316 | { |
| 1317 | // Is "(void)variable;" expression, used to remove warning about unused local variables |
| 1318 | return false; |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | if (!ignoreError) |
| 1323 | passInstance->Fail("This expression cannot be used as a statement", this); |
| 1324 | //passInstance->Fail("Only assignment, call, increment, decrement, and allocation expressions can be used as a statement", this); |
| 1325 | return false; |
| 1326 | } |
| 1327 | return true; |
| 1328 | } |
| 1329 | |
| 1330 | ////////////////////////////////////////////////////////////////////////// |
| 1331 |
no test coverage detected