mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 498434 - Floating-point literal with leading zero
Change-Id: I7417405ae89b41c7d3b28089320cc66f1c7c6173
This commit is contained in:
parent
035520ee89
commit
69fb4ee9cd
2 changed files with 27 additions and 7 deletions
|
@ -11785,6 +11785,14 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
assertTrue(test.getType() instanceof IProblemType); // resolution is ambiguous
|
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() {
|
// char foo() {
|
||||||
// return '*';
|
// return '*';
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -444,8 +444,12 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
while (Character.isDigit(c) && i < fValue.length) {
|
while (Character.isDigit(c) && i < fValue.length) {
|
||||||
c = fValue[++i];
|
c = fValue[++i];
|
||||||
}
|
}
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A floating-point constant could also have a leading zero
|
||||||
|
*/
|
||||||
|
return handleDecimalOrExponent(c, i);
|
||||||
} else if (Character.isDigit(c)) {
|
} else if (Character.isDigit(c)) {
|
||||||
/* decimal-literal :
|
/* decimal-literal :
|
||||||
* nonzero-digit (c has to be this to get into this else)
|
* nonzero-digit (c has to be this to get into this else)
|
||||||
|
@ -456,11 +460,7 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
c = fValue[++i];
|
c = fValue[++i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '.') {
|
return handleDecimalOrExponent(c, i);
|
||||||
return afterDecimalPoint(i);
|
|
||||||
} else if ((c | 0x20) == 'e') {
|
|
||||||
return exponentPart(i);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Somehow we got called and there wasn't a digit
|
// Somehow we got called and there wasn't a digit
|
||||||
// Shouldn't get here
|
// Shouldn't get here
|
||||||
|
@ -470,6 +470,18 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
|
||||||
return i;
|
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] == '.'
|
* Called with the expectation that fValue[i] == '.'
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue