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()); boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar());
switch (node.getOperator()) { switch (node.getOperator()) {
case IASTBinaryExpression.op_pmdot:
case IASTBinaryExpression.op_pmarrow:
scribe.printNextToken(nextToken, false);
break;
case IASTBinaryExpression.op_assign: case IASTBinaryExpression.op_assign:
case IASTBinaryExpression.op_binaryAndAssign: case IASTBinaryExpression.op_binaryAndAssign:
case IASTBinaryExpression.op_binaryOrAssign: case IASTBinaryExpression.op_binaryOrAssign:

View file

@ -307,7 +307,10 @@ public class SimpleScanner {
c = getChar(); c = getChar();
} }
if (!hex && c == '.') { if (!hex) {
if (c == '*') {
return newToken(Token.tDOTSTAR);
} else if (c == '.') {
if (floatingPoint && digits == 0) { if (floatingPoint && digits == 0) {
// encountered .. // encountered ..
if ((c= getChar()) == '.') { if ((c= getChar()) == '.') {
@ -325,12 +328,8 @@ public class SimpleScanner {
++digits; ++digits;
c = getChar(); c = getChar();
} }
} } else if (digits > 0 && (c == 'e' || c == 'E')) {
if (!hex && digits > 0 && (c == 'e' || c == 'E')) {
if (!floatingPoint) {
floatingPoint = true; floatingPoint = true;
}
// exponent type for floating point // exponent type for floating point
c = getChar(); c = getChar();
@ -344,12 +343,8 @@ public class SimpleScanner {
while ((c >= '0' && c <= '9')) { while ((c >= '0' && c <= '9')) {
c = getChar(); c = getChar();
} }
// optional suffix
if (c == 'l' || c == 'L' || c == 'f' || c == 'F') {
c = getChar();
} }
} else { }
if (floatingPoint) { if (floatingPoint) {
if (digits > 0) { if (digits > 0) {
//floating-suffix //floating-suffix
@ -372,7 +367,6 @@ public class SimpleScanner {
c = getChar(); c = getChar();
} }
} }
}
ungetChar(c); 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); fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, CCorePlugin.INSERT);
assertFormatterResult(); assertFormatterResult();
} }
//void Foo::bar() {
//*this.*FncPointer () ; this->*FncPointer( ); }
//void Foo::bar() {
// *this.*FncPointer();
// this->*FncPointer();
//}
public void testDotStarAndArrowStarOperators_Bug257700() throws Exception {
assertFormatterResult();
}
} }