1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 257700 - Wrong formatting of C++ class when using value of function pointer

This commit is contained in:
Anton Leherbauer 2008-12-15 13:35:12 +00:00
parent 78b78b4812
commit 4eea923bc7
3 changed files with 73 additions and 64 deletions

View file

@ -2094,6 +2094,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar());
switch (node.getOperator()) {
case IASTBinaryExpression.op_pmdot:
case IASTBinaryExpression.op_pmarrow:
scribe.printNextToken(nextToken, false);
break;
case IASTBinaryExpression.op_assign:
case IASTBinaryExpression.op_binaryAndAssign:
case IASTBinaryExpression.op_binaryOrAssign:

View file

@ -307,71 +307,65 @@ public class SimpleScanner {
c = getChar();
}
if (!hex && c == '.') {
if (floatingPoint && digits == 0) {
// encountered ..
if ((c= getChar()) == '.') {
return newToken(Token.tELIPSE);
} else {
ungetChar(c);
ungetChar('.');
return newToken(Token.tDOT);
}
}
if (!hex) {
if (c == '*') {
return newToken(Token.tDOTSTAR);
} else if (c == '.') {
if (floatingPoint && digits == 0) {
// encountered ..
if ((c= getChar()) == '.') {
return newToken(Token.tELIPSE);
} else {
ungetChar(c);
ungetChar('.');
return newToken(Token.tDOT);
}
}
floatingPoint = true;
c = getChar();
while ((c >= '0' && c <= '9')) {
++digits;
c = getChar();
}
floatingPoint = true;
c = getChar();
while ((c >= '0' && c <= '9')) {
++digits;
c = getChar();
}
} else if (digits > 0 && (c == 'e' || c == 'E')) {
floatingPoint = true;
// exponent type for floating point
c = getChar();
// optional + or -
if (c == '+' || c == '-') {
c = getChar();
}
// digit sequence of exponent part
while ((c >= '0' && c <= '9')) {
c = getChar();
}
}
}
if (!hex && digits > 0 && (c == 'e' || c == 'E')) {
if (!floatingPoint) {
floatingPoint = true;
}
// exponent type for floating point
c = getChar();
// optional + or -
if (c == '+' || c == '-') {
c = getChar();
}
// digit sequence of exponent part
while ((c >= '0' && c <= '9')) {
c = getChar();
}
// optional suffix
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
c = getChar();
}
if (floatingPoint) {
if (digits > 0) {
//floating-suffix
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
c = getChar();
}
} else {
ungetChar(c);
return newToken(Token.tDOT);
}
} else {
if (floatingPoint) {
if (digits > 0) {
//floating-suffix
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
c = getChar();
}
} else {
ungetChar(c);
return newToken(Token.tDOT);
}
} else {
//integer suffix
if (c == 'u' || c == 'U') {
c = getChar();
if (c == 'l' || c == 'L')
c = getChar();
} else if (c == 'l' || c == 'L') {
c = getChar();
if (c == 'u' || c == 'U')
c = getChar();
}
}
//integer suffix
if (c == 'u' || c == 'U') {
c = getChar();
if (c == 'l' || c == 'L')
c = getChar();
} else if (c == 'l' || c == 'L') {
c = getChar();
if (c == 'u' || c == 'U')
c = getChar();
}
}
ungetChar(c);

View file

@ -1080,4 +1080,15 @@ public class CodeFormatterTest extends BaseUITestCase {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, CCorePlugin.INSERT);
assertFormatterResult();
}
//void Foo::bar() {
//*this.*FncPointer () ; this->*FncPointer( ); }
//void Foo::bar() {
// *this.*FncPointer();
// this->*FncPointer();
//}
public void testDotStarAndArrowStarOperators_Bug257700() throws Exception {
assertFormatterResult();
}
}