1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 580062 - Self assignment check fix

Fix for false positive error in assignment operator checker
when a noexcept specifier is used.

Change-Id: If82788cda4a37af1c628a937a6960f59de6b0f5b
This commit is contained in:
Marco Stornelli 2022-06-01 13:59:41 +02:00 committed by Jonah Graham
parent a60ea13d40
commit b390885211
2 changed files with 17 additions and 1 deletions

View file

@ -112,7 +112,7 @@ public class AssignmentOperatorChecker extends AbstractIndexAstChecker {
reportProblem(MISS_SELF_CHECK_ID, info.decl);
}
info.decl = null;
} else {
} else if (expression.getPropertyInParent() != ICPPASTFunctionDeclarator.NOEXCEPT_EXPRESSION) {
reportProblem(MISS_SELF_CHECK_ID, info.decl);
info.decl = null;
}

View file

@ -47,6 +47,22 @@ public class AssignmentOperatorCheckerTest extends CheckerTestCase {
checkNoErrorsOfKind(MISS_SELF_ID);
}
//class Foo {
//public:
//Foo& operator=(Foo& f) noexcept (false);
//};
//Foo& Foo::operator=(Foo& f) noexcept (false) {
// if (this != &f) {
// return *this;
// }
// return *this;
//}
public void testWithNoErrorNoexcept() throws Exception {
loadCodeAndRun(getAboveComment());
checkNoErrorsOfKind(MISS_REF_ID);
checkNoErrorsOfKind(MISS_SELF_ID);
}
//class Foo {
//public:
//Foo operator=(const Foo& f);