mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fixed reporting of error in empty constructor
This commit is contained in:
parent
36843b8c72
commit
38bd4a6094
1 changed files with 18 additions and 13 deletions
|
@ -96,7 +96,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
||||||
if (hasret == false && hasValue) {
|
if (hasret == false && hasValue) {
|
||||||
hasret = true;
|
hasret = true;
|
||||||
}
|
}
|
||||||
if (!isVoid(func) && !isConstructorDestructor()) {
|
if (!isVoid(func) && !isConstructorDestructor(func)) {
|
||||||
if (checkImplicitReturn(RET_NO_VALUE_ID) || isExplicitReturn(func)) {
|
if (checkImplicitReturn(RET_NO_VALUE_ID) || isExplicitReturn(func)) {
|
||||||
if (!hasValue)
|
if (!hasValue)
|
||||||
reportProblem(RET_NO_VALUE_ID, ret);
|
reportProblem(RET_NO_VALUE_ID, ret);
|
||||||
|
@ -113,20 +113,21 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @param func
|
||||||
*
|
* @return
|
||||||
*/
|
*
|
||||||
public boolean isConstructorDestructor() {
|
*/
|
||||||
if (func instanceof ICPPASTFunctionDefinition) {
|
public boolean isConstructorDestructor(IASTFunctionDefinition func) {
|
||||||
IBinding method = func.getDeclarator().getName().resolveBinding();
|
if (func instanceof ICPPASTFunctionDefinition) {
|
||||||
if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod) method).isDestructor()) {
|
IBinding method = func.getDeclarator().getName().resolveBinding();
|
||||||
return true;
|
if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod) method).isDestructor()) {
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -157,7 +158,8 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
||||||
reportNoRet(func, visitor.hasret);
|
reportNoRet(func, visitor.hasret);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reportNoRet(func, false);
|
|
||||||
|
reportNoRet(func, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,6 +174,9 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
||||||
if (checkImplicitReturn(RET_NORET_ID) == false && isExplicitReturn(func) == false) {
|
if (checkImplicitReturn(RET_NORET_ID) == false && isExplicitReturn(func) == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isConstructorDestructor(func)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reportProblem(RET_NORET_ID, func.getDeclSpecifier());
|
reportProblem(RET_NORET_ID, func.getDeclSpecifier());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue