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 faf14a021a9..e24e2a0e1e5 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 @@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; @@ -185,6 +186,15 @@ public class DOMLocationTests extends AST2BaseTest { ICPPASTNamedTypeSpecifier namedTypeSpec = (ICPPASTNamedTypeSpecifier) b.getDeclSpecifier(); assertSoleLocation( namedTypeSpec, code.indexOf( "\nA") + 1, 1 ); //$NON-NLS-1$ } + + public void testBug84366() throws Exception { + String code = "enum hue { red, blue, green };"; //$NON-NLS-1$ + IASTTranslationUnit tu = parse( code, ParserLanguage.CPP ); + IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0]; + IASTEnumerationSpecifier enum = (IASTEnumerationSpecifier) d.getDeclSpecifier(); + IASTEnumerationSpecifier.IASTEnumerator enumerator = enum.getEnumerators()[0]; + assertSoleLocation( enumerator, code.indexOf( "red"), "red".length() ); //$NON-NLS-1$ //$NON-NLS-2$ + } public void testBug84375() throws Exception { String code = "class D { public: int x; };\nclass C : public virtual D {};"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index febc206beea..3aeeba57693 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -4428,7 +4428,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { * @see org.eclipse.cdt.internal.core.parser2.AbstractGNUSourceCodeParser#createName(org.eclipse.cdt.core.parser.IToken) */ protected IASTName createName(IToken token) { - return new CPPASTName(token.getCharImage()); + CPPASTName n = new CPPASTName(token.getCharImage()); + n.setOffsetAndLength( token.getOffset(), token.getLength() ); + return n; } /*