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 46180 Details for
Bug 150074
[compiler] init part of for each loop with empty body is not executed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Last patch
patch_150074.txt (text/plain), 6.31 KB, created by
Olivier Thomann
on 2006-07-12 12:02:26 EDT
(
hide
)
Description:
Last patch
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2006-07-12 12:02:26 EDT
Size:
6.31 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v >retrieving revision 1.40 >diff -u -r1.40 ForeachStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 12 Jul 2006 09:51:54 -0000 1.40 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 12 Jul 2006 16:00:36 -0000 >@@ -124,20 +124,23 @@ > > // we need the variable to iterate the collection even if the > // element variable is not used >- if (!(this.action == null >+ final boolean hasEmptyAction = this.action == null > || this.action.isEmptyBlock() >- || ((this.action.bits & IsUsefulEmptyStatement) != 0))) { >- switch(this.kind) { >- case ARRAY : >+ || ((this.action.bits & IsUsefulEmptyStatement) != 0); >+ >+ switch(this.kind) { >+ case ARRAY : >+ if (!hasEmptyAction >+ || this.elementVariable.binding.resolvedPosition != -1) { > this.collectionVariable.useFlag = LocalVariableBinding.USED; > this.indexVariable.useFlag = LocalVariableBinding.USED; > this.maxVariable.useFlag = LocalVariableBinding.USED; >- break; >- case RAW_ITERABLE : >- case GENERIC_ITERABLE : >- this.indexVariable.useFlag = LocalVariableBinding.USED; >- break; >- } >+ } >+ break; >+ case RAW_ITERABLE : >+ case GENERIC_ITERABLE : >+ this.indexVariable.useFlag = LocalVariableBinding.USED; >+ break; > } > //end of loop > loopingContext.complainOnDeferredNullChecks(currentScope, actionInfo); >@@ -167,9 +170,14 @@ > return; > } > int pc = codeStream.position; >- if (this.action == null >- || this.action.isEmptyBlock() >- || ((this.action.bits & IsUsefulEmptyStatement) != 0)) { >+ final boolean hasEmptyAction = this.action == null >+ || this.action.isEmptyBlock() >+ || ((this.action.bits & IsUsefulEmptyStatement) != 0); >+ >+ if (hasEmptyAction >+ && this.elementVariable.binding.resolvedPosition == -1 >+ && this.kind == ARRAY) { >+ collection.generateCode(scope, codeStream, false); > codeStream.exitUserScope(scope); > if (mergedInitStateIndex != -1) { > codeStream.removeNotDefinitelyAssignedVariables(currentScope, mergedInitStateIndex); >@@ -178,6 +186,7 @@ > codeStream.recordPositionsFrom(pc, this.sourceStart); > return; > } >+ > // generate the initializations > switch(this.kind) { > case ARRAY : >@@ -209,7 +218,6 @@ > codeStream.store(this.indexVariable, false); > break; > } >- > // label management > BranchLabel actionLabel = new BranchLabel(codeStream); > actionLabel.tagBits |= BranchLabel.USED; >@@ -227,9 +235,9 @@ > actionLabel.place(); > > // generate the loop action >- if (this.elementVariable.binding.resolvedPosition != -1) { >- switch(this.kind) { >- case ARRAY : >+ switch(this.kind) { >+ case ARRAY : >+ if (this.elementVariable.binding.resolvedPosition != -1) { > codeStream.load(this.collectionVariable); > codeStream.load(this.indexVariable); > codeStream.arrayAt(this.collectionElementType.id); >@@ -237,43 +245,43 @@ > codeStream.generateImplicitConversion(this.elementVariableImplicitWidening); > } > codeStream.store(this.elementVariable.binding, false); >- break; >- case RAW_ITERABLE : >- case GENERIC_ITERABLE : >- codeStream.load(this.indexVariable); >- codeStream.invokeJavaUtilIteratorNext(); >- if (this.elementVariable.binding.type.id != T_JavaLangObject) { >- if (this.elementVariableImplicitWidening != -1) { >- codeStream.checkcast(this.collectionElementType); >- codeStream.generateImplicitConversion(this.elementVariableImplicitWidening); >- } else { >- codeStream.checkcast(this.elementVariable.binding.type); >- } >+ codeStream.addVisibleLocalVariable(this.elementVariable.binding); >+ if (this.postCollectionInitStateIndex != -1) { >+ codeStream.addDefinitelyAssignedVariables( >+ currentScope, >+ this.postCollectionInitStateIndex); > } >- codeStream.store(this.elementVariable.binding, false); >- break; >- } >- codeStream.addVisibleLocalVariable(this.elementVariable.binding); >- if (this.postCollectionInitStateIndex != -1) { >- codeStream.addDefinitelyAssignedVariables( >- currentScope, >- this.postCollectionInitStateIndex); >- } >- } else { >- // if unused variable, some side effects still need to be performed (86487) >- switch(this.kind) { >- case ARRAY : >- break; >- case RAW_ITERABLE : >- case GENERIC_ITERABLE : >- // still advance in iterator to prevent infinite loop >- codeStream.load(this.indexVariable); >- codeStream.invokeJavaUtilIteratorNext(); >+ } >+ break; >+ case RAW_ITERABLE : >+ case GENERIC_ITERABLE : >+ codeStream.load(this.indexVariable); >+ codeStream.invokeJavaUtilIteratorNext(); >+ if (this.elementVariable.binding.type.id != T_JavaLangObject) { >+ if (this.elementVariableImplicitWidening != -1) { >+ codeStream.checkcast(this.collectionElementType); >+ codeStream.generateImplicitConversion(this.elementVariableImplicitWidening); >+ } else { >+ codeStream.checkcast(this.elementVariable.binding.type); >+ } >+ } >+ if (this.elementVariable.binding.resolvedPosition == -1) { > codeStream.pop(); >- break; >- } >+ } else { >+ codeStream.store(this.elementVariable.binding, false); >+ codeStream.addVisibleLocalVariable(this.elementVariable.binding); >+ if (this.postCollectionInitStateIndex != -1) { >+ codeStream.addDefinitelyAssignedVariables( >+ currentScope, >+ this.postCollectionInitStateIndex); >+ } >+ } >+ break; >+ } >+ >+ if (!hasEmptyAction) { >+ this.action.generateCode(scope, codeStream); > } >- this.action.generateCode(scope, codeStream); > > // continuation point > if (this.continueLabel != null) { >@@ -282,6 +290,7 @@ > // generate the increments for next iteration > switch(this.kind) { > case ARRAY : >+ if (hasEmptyAction && this.elementVariable.binding.resolvedPosition == -1) break; > codeStream.iinc(this.indexVariable.resolvedPosition, 1); > break; > case RAW_ITERABLE :
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 150074
:
46069
|
46070
|
46072
|
46078
|
46079
| 46180 |
46181