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 4b9e6991b58..7f1f6309b95 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 @@ -40,6 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorObjectStyleMacroDefinition; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement; +import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; @@ -63,7 +64,11 @@ public class DOMLocationTests extends AST2BaseTest { private static final String _TEXT_ = ""; //$NON-NLS-1$ - public void testBaseCase() throws ParserException { + public DOMLocationTests(String name) { + setName(name); + } + + public void testBaseCase() throws ParserException { for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP : null) { IASTTranslationUnit tu = parse("int x;", p); //$NON-NLS-1$ @@ -444,6 +449,25 @@ public class DOMLocationTests extends AST2BaseTest { } } + public void _testBug162180() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append( "#include \n"); //$NON-NLS-1$ + int declOffset= buffer.length(); + buffer.append( "int x;\n"); //$NON-NLS-1$ + String code = buffer.toString(); + for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP + : null) { + IASTTranslationUnit tu = parse(code, p, false, false); + IASTDeclaration[] decls= tu.getDeclarations(); + assertEquals( decls.length, 1 ); + IASTPreprocessorStatement [] statements = tu.getAllPreprocessorStatements(); + assertEquals( statements.length, 0 ); + IASTProblem[] problems = tu.getPreprocessorProblems(); + assertEquals( problems.length, 1 ); + assertSoleLocation( decls[0], code.indexOf( "int x;"), "int x;".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 ); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java index 28791046112..41bcbe98cc7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java @@ -16,6 +16,7 @@ import junit.framework.TestSuite; import org.eclipse.cdt.core.parser.tests.ParserTestSuite; import org.eclipse.cdt.core.parser.tests.prefix.CompletionTestSuite; +import org.eclipse.cdt.core.tests.FailingTest; /** * @author jcamelon @@ -31,6 +32,7 @@ public class DOMParserTestSuite extends TestCase { suite.addTestSuite( QuickParser2Tests.class ); suite.addTestSuite( CompleteParser2Tests.class ); suite.addTestSuite( DOMLocationTests.class ); + suite.addTest( new FailingTest(new DOMLocationTests("_testBug162180"), 162180) ); suite.addTestSuite( DOMLocationMacroTests.class ); suite.addTest( DOMLocationInclusionTests.suite() ); suite.addTestSuite( AST2KnRTests.class );