Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndrew Niefer2004-10-07 14:51:36 -0400
committerAndrew Niefer2004-10-07 14:51:36 -0400
commit654fb767a2a5e88242ccee36c57e1188bce2cf80 (patch)
tree5e9e262a9f2dc56e93577195a62f4914cdf073eb /core
parentdc2c9cec11dcdda08ef956744eb572cfc735f152 (diff)
downloadorg.eclipse.cdt-654fb767a2a5e88242ccee36c57e1188bce2cf80.tar.gz
org.eclipse.cdt-654fb767a2a5e88242ccee36c57e1188bce2cf80.tar.xz
org.eclipse.cdt-654fb767a2a5e88242ccee36c57e1188bce2cf80.zip
Patch from Devin Steffler: [Scanner] Wrong compare if the two declarations are in other number system
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ExpressionEvaluator.java4
2 files changed, 24 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
index ea1ce74af1a..5c9083f0fd5 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
@@ -14,6 +14,7 @@ import java.io.StringWriter;
import java.io.Writer;
import java.util.Iterator;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
@@ -2241,5 +2242,26 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
IASTTypeId typeId = (IASTTypeId) typeIds.next();
assertEquals( typeId.getTypeOrClassName(), "Thrown" );
}
+
+ public void testBug75532() throws Exception
+ {
+ try {
+ Writer writer = new StringWriter();
+ writer.write( "#if 2147483647 == 0x7fffffff\n");
+ writer.write( "#error This was equal, but not for the eclipse.\n");
+ writer.write( "#endif\n");
+ parse( writer.toString() );
+
+ assertTrue(false);
+ } catch (ParserException pe) {
+ // expected IProblem
+ } finally {
+ assertTrue( callback.getProblems().hasNext() );
+ Object ipo = callback.getProblems().next();
+ assertTrue( ipo instanceof IProblem );
+ IProblem ip = (IProblem)callback.getProblems().next();
+ assertTrue(ip.getArguments().indexOf("This was equal, but not for the eclipse") > 0);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ExpressionEvaluator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ExpressionEvaluator.java
index 69df17a94cf..5c7847b9927 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ExpressionEvaluator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ExpressionEvaluator.java
@@ -459,11 +459,11 @@ public class ExpressionEvaluator {
continue;
} else if (isHex) {
if (c >= 'a' && c <= 'f') {
- tokenValue *= 16;
+ tokenValue = (tokenValue == 0 ? 10 : (tokenValue * 16) + 10);
tokenValue += c - 'a';
continue;
} else if (c >= 'A' && c <= 'F') {
- tokenValue *= 16;
+ tokenValue = (tokenValue == 0 ? 10 : (tokenValue * 16) + 10);
tokenValue += c - 'A';
continue;
}

Back to the top