Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 223553 Details for
Bug 355938
False positive warning about return value with try/catch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch that fixes the issue, including tests
bug355938.patch (text/plain), 4.33 KB, created by
Nathan Ridge
on 2012-11-14 05:09:35 EST
(
hide
)
Description:
patch that fixes the issue, including tests
Filename:
MIME Type:
Creator:
Nathan Ridge
Created:
2012-11-14 05:09:35 EST
Size:
4.33 KB
patch
obsolete
>diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java >index 07825aa..c6db7bb 100644 >--- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java >+++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnChecker.java >@@ -47,6 +47,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLambdaExpression; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; >+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; > >@@ -206,7 +207,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 IASTSwitchStatement || last instanceof IASTCompoundStatement || >+ last instanceof ICPPASTTryBlockStatement; > } > > protected boolean isFuncExitStatement(IASTStatement statement) { >diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java >index 22076c9..5594f56 100644 >--- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java >+++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/internal/model/cfg/ControlFlowGraphBuilder.java >@@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IASTBreakStatement; > import org.eclipse.cdt.core.dom.ast.IASTCaseStatement; > import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; > import org.eclipse.cdt.core.dom.ast.IASTContinueStatement; >+import org.eclipse.cdt.core.dom.ast.IASTDeclaration; > import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; > import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement; > import org.eclipse.cdt.core.dom.ast.IASTDoStatement; >@@ -238,7 +239,13 @@ public class ControlFlowGraphBuilder { > ICPPASTCatchHandler[] catchHandlers = body.getCatchHandlers(); > for (int i = 0; i < catchHandlers.length; i++) { > ICPPASTCatchHandler handler = catchHandlers[i]; >- IBranchNode handlerNode = factory.createBranchNode(handler.getDeclaration()); >+ IASTDeclaration handlerDecl = handler.getDeclaration(); >+ // handlerDecl might be null if the handler is of the form 'catch (...)' >+ IBranchNode handlerNode; >+ if (handlerDecl == null) >+ handlerNode = factory.createBranchNode("..."); //$NON-NLS-1$ >+ else >+ handlerNode = factory.createBranchNode(handler.getDeclaration()); > addOutgoing(ifNode, handlerNode); > IBasicBlock els = createSubGraph(handlerNode, handler.getCatchBody()); > addJump(els, mergeNode); >diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java >index 7558446..a9ec4a7 100644 >--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java >+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java >@@ -310,4 +310,27 @@ public class ReturnCheckerTest extends CheckerTestCase { > loadCodeAndRun(getAboveComment()); > checkNoErrors(); > } >+ >+ // int foo() { >+ // try { >+ // return 1; >+ // } catch (...) { >+ // return 0; >+ // } >+ // } >+ public void testTryCatch1_Bug355938() { >+ loadCodeAndRunCpp(getAboveComment()); >+ checkNoErrors(); >+ } >+ >+ // int foo() { >+ // try { >+ // return 1; >+ // } catch (...) { >+ // } >+ // } >+ public void testTryCatch2_Bug355938() { >+ loadCodeAndRunCpp(getAboveComment()); >+ checkErrorLine(1); >+ } > } >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 355938
: 223553