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

(-)compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java (-1 / +3 lines)
Lines 811-817 Link Here
811
811
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
					&& this.left.resolvedType != TypeBinding.DOUBLE) {
816
				// Double.NaN == Double.NaN => false
815
				scope.problemReporter().comparingIdenticalExpressions(this);
817
				scope.problemReporter().comparingIdenticalExpressions(this);
816
			}
818
			}
817
			return this.resolvedType = TypeBinding.BOOLEAN;
819
			return this.resolvedType = TypeBinding.BOOLEAN;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java (-9 / +51 lines)
Lines 26-50 Link Here
26
public class ProgrammingProblemsTest extends AbstractRegressionTest {
26
public class ProgrammingProblemsTest extends AbstractRegressionTest {
27
27
28
public ProgrammingProblemsTest(String name) {
28
public ProgrammingProblemsTest(String name) {
29
    super(name);
29
	super(name);
30
}
30
}
31
31
32
	// Static initializer to specify tests subset using TESTS_* static variables
32
	// Static initializer to specify tests subset using TESTS_* static variables
33
  	// All specified tests which does not belong to the class are skipped...
33
	// All specified tests which does not belong to the class are skipped...
34
  	// Only the highest compliance level is run; add the VM argument
34
	// Only the highest compliance level is run; add the VM argument
35
  	// -Dcompliance=1.4 (for example) to lower it if needed
35
	// -Dcompliance=1.4 (for example) to lower it if needed
36
  	static {
36
	static {
37
//    	TESTS_NAMES = new String[] { "test001" };
37
//    	TESTS_NAMES = new String[] { "test001" };
38
//    	TESTS_NUMBERS = new int[] { 1 };
38
//		TESTS_NUMBERS = new int[] { 39 };
39
//  	TESTS_RANGE = new int[] { 1, -1 };
39
//  	TESTS_RANGE = new int[] { 1, -1 };
40
  	}
40
	}
41
41
42
public static Test suite() {
42
public static Test suite() {
43
    return buildAllCompliancesTestSuite(testClass());
43
	return buildAllCompliancesTestSuite(testClass());
44
}
44
}
45
45
46
public static Class testClass() {
46
public static Class testClass() {
47
    return ProgrammingProblemsTest.class;
47
	return ProgrammingProblemsTest.class;
48
}
48
}
49
49
50
void runTest(
50
void runTest(
Lines 1399-1402 Link Here
1399
			"Zork cannot be resolved to a type\n" +
1399
			"Zork cannot be resolved to a type\n" +
1400
			"----------\n");
1400
			"----------\n");
1401
}
1401
}
1402
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251227
1403
public void test0038() {
1404
	Map options = getCompilerOptions();
1405
	options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR);
1406
	this.runConformTest(
1407
		new String[] {
1408
			"X.java",
1409
			"public class X {\n" +
1410
			"	public static void main(String[] args) {\n" +
1411
			"		double d1 = 0.0;\n" +
1412
			"		System.out.println(d1 == d1);\n" +
1413
			"	}\n" +
1414
			"}\n"
1415
		},
1416
		"true",
1417
		null,
1418
		true,
1419
		null,
1420
		options,
1421
		null);
1422
}
1423
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=251227
1424
public void test0039() {
1425
	Map options = getCompilerOptions();
1426
	options.put(CompilerOptions.OPTION_ReportComparingIdentical, CompilerOptions.ERROR);
1427
	this.runConformTest(
1428
		new String[] {
1429
			"X.java",
1430
			"public class X {\n" +
1431
			"	public static void main(String[] args) {\n" +
1432
			"		double d1 = Double.NaN;\n" +
1433
			"		System.out.println(d1 == d1);\n" +
1434
			"	}\n" +
1435
			"}\n"
1436
		},
1437
		"false",
1438
		null,
1439
		true,
1440
		null,
1441
		options,
1442
		null);
1443
}
1402
}
1444
}

Return to bug 251227