### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java,v retrieving revision 1.88 diff -u -r1.88 Assignment.java --- compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 7 Mar 2009 00:58:57 -0000 1.88 +++ compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java 13 Jul 2010 15:26:39 -0000 @@ -160,7 +160,7 @@ } // check for assignment with no effect Binding left = getDirectBinding(this.lhs); - if (left != null && left == getDirectBinding(this.expression)) { + if (left != null && !left.isVolatile() && left == getDirectBinding(this.expression)) { scope.problemReporter().assignmentHasNoEffect(this, left.shortReadableName()); } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java,v retrieving revision 1.35 diff -u -r1.35 Binding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java 24 Sep 2008 16:05:23 -0000 1.35 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Binding.java 13 Jul 2010 15:26:39 -0000 @@ -91,6 +91,9 @@ public final boolean isValidBinding() { return problemId() == ProblemReasons.NoError; } + public boolean isVolatile() { + return false; + } /* API * Answer the problem id associated with the receiver. * NoError if the receiver is a valid binding. #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v retrieving revision 1.22 diff -u -r1.22 ProgrammingProblemsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 18 Jun 2010 15:51:58 -0000 1.22 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 13 Jul 2010 15:26:44 -0000 @@ -1638,4 +1638,49 @@ "a cannot be resolved to a variable\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310264 +public void test0044() { + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n" + + " volatile int x;\n" + + " int nvx;\n" + + " void foo(int i) {\n" + + " x = x;\n" + + " nvx = nvx;\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. WARNING in X.java (at line 6)\n" + + " nvx = nvx;\n" + + " ^^^^^^^^^\n" + + "The assignment to variable nvx has no effect\n" + + "----------\n"); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310264 +public void test0045() { + this.runNegativeTest( + new String[] { + "X.java", + "class X {\n" + + " volatile int x = this.x;\n" + + " int nvx = this.nvx;\n" + + " void foo(int i) {\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. WARNING in X.java (at line 2)\n" + + " volatile int x = this.x;\n" + + " ^^^^^^^^^^\n" + + "The assignment to variable x has no effect\n" + + "----------\n" + + "2. WARNING in X.java (at line 3)\n" + + " int nvx = this.nvx;\n" + + " ^^^^^^^^^^^^^^\n" + + "The assignment to variable nvx has no effect\n" + + "----------\n"); +} } \ No newline at end of file