View | Details | Raw Unified | Return to bug 281776
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java (+30 lines)
Lines 1529-1532 Link Here
1529
			"Zork cannot be resolved to a type\n" + 
1529
			"Zork cannot be resolved to a type\n" + 
1530
			"----------\n");
1530
			"----------\n");
1531
}
1531
}
1532
/**
1533
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=281776"
1534
 * We now tolerate comparison of float and double entities against
1535
 * themselves as a legitimate idiom for NaN checking. 
1536
 */
1537
public void test0040() {
1538
	this.runNegativeTest(
1539
		new String[] {
1540
			"X.java",
1541
			"public class X {\n" +
1542
		    "    public static void main(String[] args) {\n" +
1543
		    "        double var = Double.NaN;\n" +
1544
		    "            if(var != var) {\n" +
1545
		    "                  System.out.println(\"NaN\");\n" +
1546
		    "            }\n" +
1547
		    "            float varf = 10;\n" +
1548
		    "            if(varf != varf) {\n" +
1549
		    "            	System.out.println(\"NaN\");\n" +
1550
		    "            }\n" +
1551
		    "   }\n" +
1552
			"	Zork z;\n" +
1553
			"}\n"
1554
			},
1555
			"----------\n" + 
1556
			"1. ERROR in X.java (at line 12)\n" + 
1557
			"	Zork z;\n" + 
1558
			"	^^^^\n" + 
1559
			"Zork cannot be resolved to a type\n" + 
1560
			"----------\n");
1561
}
1532
}
1562
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java (-1 / +2 lines)
Lines 812-818 Link Here
812
			// check whether comparing identical expressions
812
			// check whether comparing identical expressions
813
			Binding leftDirect = Expression.getDirectBinding(this.left);
813
			Binding leftDirect = Expression.getDirectBinding(this.left);
814
			if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) {
814
			if (leftDirect != null && leftDirect == Expression.getDirectBinding(this.right)) {
815
				scope.problemReporter().comparingIdenticalExpressions(this);
815
				if (leftTypeID != TypeIds.T_double && leftTypeID != TypeIds.T_float) // https://bugs.eclipse.org/bugs/show_bug.cgi?id=281776
816
					scope.problemReporter().comparingIdenticalExpressions(this);
816
			} else if (this.constant != Constant.NotAConstant) {
817
			} else if (this.constant != Constant.NotAConstant) {
817
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740
818
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=276740
818
				int operator = (this.bits & OperatorMASK) >> OperatorSHIFT;
819
				int operator = (this.bits & OperatorMASK) >> OperatorSHIFT;

Return to bug 281776