From 7918ac34f097d7840fbab747648eff71488b5b7e Mon Sep 17 00:00:00 2001 From: John Camelon Date: Tue, 22 Feb 2005 21:22:00 +0000 Subject: [PATCH] Fixed Bug 85820 - [Length] should IASTInitializerList's length be included in the length of it's parents? --- .../cdt/core/parser/tests/ast2/DOMLocationTests.java | 8 ++++++++ .../cdt/internal/core/dom/parser/c/GNUCSourceParser.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java index 60a6dcee4e6..3cd7f8ee44a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationTests.java @@ -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$ + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 39047e59ff3..1a9c5a23cda 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -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);