1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Fixed Bug 85820 - [Length] should IASTInitializerList's length be included in the length of it's parents?

This commit is contained in:
John Camelon 2005-02-22 21:22:00 +00:00
parent 54791bce99
commit 7918ac34f0
2 changed files with 9 additions and 1 deletions

View file

@ -440,4 +440,12 @@ public class DOMLocationTests extends AST2BaseTest {
assertSoleLocation( endif, code.indexOf( "#endif"), "#endif".length() ); //$NON-NLS-1$ //$NON-NLS-2$
}
}
public void testBug85820() throws Exception {
String code = "int *p = (int []){2, 4};"; //$NON-NLS-1$
IASTTranslationUnit tu = parse( code, ParserLanguage.C );
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclarator d = sd.getDeclarators()[0];
assertSoleLocation( d, code.indexOf("*p = (int []){2, 4}"), "*p = (int []){2, 4}".length() ); //$NON-NLS-1$//$NON-NLS-2$
}
}

View file

@ -916,7 +916,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
int lastOffset = consume(IToken.tRPAREN).getEndOffset();
IASTInitializer i = cInitializerClause(Collections.EMPTY_LIST);
firstExpression = buildTypeIdInitializerExpression(t, i,
offset, lastOffset);
offset, calculateEndOffset(i));
break;
} catch (BacktrackException bt) {
backup(m);