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) {
|
||||
hasret = true;
|
||||
}
|
||||
if (!isVoid(func) && !isConstructorDestructor()) {
|
||||
if (!isVoid(func) && !isConstructorDestructor(func)) {
|
||||
if (checkImplicitReturn(RET_NO_VALUE_ID) || isExplicitReturn(func)) {
|
||||
if (!hasValue)
|
||||
reportProblem(RET_NO_VALUE_ID, ret);
|
||||
|
@ -113,12 +113,14 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
|||
}
|
||||
return PROCESS_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param func
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public boolean isConstructorDestructor() {
|
||||
public boolean isConstructorDestructor(IASTFunctionDefinition func) {
|
||||
if (func instanceof ICPPASTFunctionDefinition) {
|
||||
IBinding method = func.getDeclarator().getName().resolveBinding();
|
||||
if (method instanceof ICPPConstructor || method instanceof ICPPMethod && ((ICPPMethod) method).isDestructor()) {
|
||||
|
@ -127,7 +129,6 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -157,6 +158,7 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
|||
reportNoRet(func, visitor.hasret);
|
||||
}
|
||||
} else {
|
||||
|
||||
reportNoRet(func, false);
|
||||
}
|
||||
}
|
||||
|
@ -172,6 +174,9 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
|||
if (checkImplicitReturn(RET_NORET_ID) == false && isExplicitReturn(func) == false) {
|
||||
return;
|
||||
}
|
||||
if (isConstructorDestructor(func)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
reportProblem(RET_NORET_ID, func.getDeclSpecifier());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue