mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 492878 - Fix no-return in function with goto
Change-Id: I39f2605aa2e5b697015a2dfdb795f163e76095cf Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
11a14b7ed3
commit
3fcbb5c7b5
2 changed files with 15 additions and 1 deletions
|
@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTLabelStatement;
|
||||
|
@ -210,7 +211,8 @@ public class ReturnChecker extends AbstractAstFunctionChecker {
|
|||
private boolean isCompoundStatement(IASTStatement last) {
|
||||
return last instanceof IASTIfStatement || last instanceof IASTWhileStatement || last instanceof IASTDoStatement
|
||||
|| last instanceof IASTForStatement || last instanceof IASTSwitchStatement
|
||||
|| last instanceof IASTCompoundStatement || last instanceof ICPPASTTryBlockStatement;
|
||||
|| last instanceof IASTCompoundStatement || last instanceof ICPPASTTryBlockStatement
|
||||
|| last instanceof IASTGotoStatement;
|
||||
}
|
||||
|
||||
protected boolean isFuncExitStatement(IASTStatement statement) {
|
||||
|
|
|
@ -515,4 +515,16 @@ public class ReturnCheckerTest extends CheckerTestCase {
|
|||
public void testTemplateFunctionNoReturn() throws Exception {
|
||||
checkSampleAboveCpp();
|
||||
}
|
||||
|
||||
//int foo() {
|
||||
// int errcode = -1;
|
||||
// errcode = 0;
|
||||
// cleanup:
|
||||
// return errcode;
|
||||
// barf:
|
||||
// goto cleanup;
|
||||
//}
|
||||
public void testNoReturnWithGoto_Bug492878() throws Exception {
|
||||
checkSampleAboveCpp();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue