1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 498434 - Floating-point literal with leading zero

Change-Id: I7417405ae89b41c7d3b28089320cc66f1c7c6173
This commit is contained in:
Nathan Ridge 2016-07-26 00:27:10 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 035520ee89
commit 69fb4ee9cd
2 changed files with 27 additions and 7 deletions

View file

@ -11785,6 +11785,14 @@ public class AST2CPPTests extends AST2TestBase {
assertTrue(test.getType() instanceof IProblemType); // resolution is ambiguous
}
// double waldo1 = 02.968;
// double waldo2 = 09.268;
// double waldo3 = 02e2;
// double waldo4 = 09e2;
public void testFloatLiteralWithLeadingZero_498434() throws Exception {
parseAndCheckImplicitNameBindings();
}
// char foo() {
// return '*';
// }

View file

@ -444,8 +444,12 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
while (Character.isDigit(c) && i < fValue.length) {
c = fValue[++i];
}
return i;
}
/*
* A floating-point constant could also have a leading zero
*/
return handleDecimalOrExponent(c, i);
} else if (Character.isDigit(c)) {
/* decimal-literal :
* nonzero-digit (c has to be this to get into this else)
@ -455,12 +459,8 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
while (Character.isDigit(c) && i < fValue.length) {
c = fValue[++i];
}
if (c == '.') {
return afterDecimalPoint(i);
} else if ((c | 0x20) == 'e') {
return exponentPart(i);
}
return handleDecimalOrExponent(c, i);
} else {
// Somehow we got called and there wasn't a digit
// Shouldn't get here
@ -470,6 +470,18 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
return i;
}
/*
* Consumes a decimal point or exponent, if present.
*/
private int handleDecimalOrExponent(char c, int i) {
if (c == '.') {
return afterDecimalPoint(i);
} else if ((c | 0x20) == 'e') {
return exponentPart(i);
}
return i;
}
/*
* Called with the expectation that fValue[i] == '.'
*/