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 173258 Details for
Bug 318571
warning of unued variable gets tricked by i++;
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed patch
bug_318571.patch (text/plain), 2.53 KB, created by
Stephan Herrmann
on 2010-07-01 17:27:21 EDT
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2010-07-01 17:27:21 EDT
Size:
2.53 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.117 >diff -u -r1.117 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 7 Apr 2010 12:47:50 -0000 1.117 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 1 Jul 2010 21:07:23 -0000 >@@ -77,9 +77,7 @@ > currentScope.problemReporter().uninitializedLocalVariable(localBinding, this); > // we could improve error msg here telling "cannot use compound assignment on final local variable" > } >- if (isReachable) { >- localBinding.useFlag = LocalVariableBinding.USED; >- } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) { >+ if (localBinding.useFlag == LocalVariableBinding.UNUSED) { > localBinding.useFlag = LocalVariableBinding.FAKE_USED; > } > } >@@ -461,6 +459,14 @@ > * are optimized in one access: e.g "a = a + 1" optimized into "a++". > */ > public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { >+ if (!valueRequired && ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL)) { >+ LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; >+ if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) { >+ // report the case of a local variable that is unread except for this compound assignment >+ currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); >+ localBinding.useFlag = LocalVariableBinding.USED; // don't report again >+ } >+ } > this.generateCompoundAssignment( > currentScope, > codeStream, >@@ -661,6 +667,15 @@ > return; > case Binding.LOCAL : // assigning to a local variable > LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; >+ >+ if (!valueRequired) { >+ if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) { >+ // report the case of a local variable that is unread except for postIncrement expressions >+ currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); >+ localBinding.useFlag = LocalVariableBinding.USED; // don't report again >+ } >+ } >+ > // using incr bytecode if possible > if (localBinding.type == TypeBinding.INT) { > if (valueRequired) {
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 318571
:
173190
|
173191
|
173192
| 173258