diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java index 4952e97c4e0..d753e773f5a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java @@ -306,6 +306,39 @@ public class DOMLocationInclusionTests extends FileBasePluginTest { macroDefinitions[5], "blarg.c", c_file_code.indexOf("#define POST_SECOND"), "#define POST_SECOND".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ } + } + + public void testBug87894() throws Exception { + StringBuffer fakeBuffer = new StringBuffer( "// windows_fake.h:\n" ); //$NON-NLS-1$ + fakeBuffer.append( "#ifdef RC_INVOKED\n" ); //$NON-NLS-1$ + fakeBuffer.append( "#define WIN32_LEAN_AND_MEAN\n" ); //$NON-NLS-1$ + fakeBuffer.append( "#endif\n" ); //$NON-NLS-1$ + fakeBuffer.append( "\n" ); //$NON-NLS-1$ + fakeBuffer.append( "#ifndef WIN32_LEAN_AND_MEAN\n" ); //$NON-NLS-1$ + fakeBuffer.append( "#include \"rpc_fake.h\"\n" ); //$NON-NLS-1$ + fakeBuffer.append( "#endif)\n" ); //$NON-NLS-1$ + String windows_fake_h_code = fakeBuffer.toString(); + importFile( "windows_fake.h", windows_fake_h_code ); //$NON-NLS-1$ + StringBuffer rpcBuffer = new StringBuffer(); + rpcBuffer.append( "// rpc_fake.h:\n" ); //$NON-NLS-1$ + rpcBuffer.append( "#define RC_INVOKED\n" ); //$NON-NLS-1$ + rpcBuffer.append( "\n" ); //$NON-NLS-1$ + rpcBuffer.append( "#ifndef RPC_NO_WINDOWS_H\n" ); //$NON-NLS-1$ + rpcBuffer.append( "#include \"windows_fake.h\"\n" ); //$NON-NLS-1$ + rpcBuffer.append( "#endif\n" ); //$NON-NLS-1$ + String rpc_fake_h_code = rpcBuffer.toString(); + importFile( "rpc_fake.h", rpc_fake_h_code ); //$NON-NLS-1$ + String test_c_code = "// test.c:\n#include \"windows_fake.h\"\n // endOffset is 64 but should be more like 266"; //$NON-NLS-1$ + IFile f = importFile( "test.c", test_c_code ); //$NON-NLS-1$ + for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP + : null) { + IASTTranslationUnit tu = parse(f, p); //$NON-NLS-1$ + + } + + + + } public static Test suite() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java index 5f63c117c4f..59da8adb0a1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java @@ -2202,7 +2202,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { foundContext = tempContext; break; } - foundContext = findInclusion(context, path); + foundContext = findInclusion(tempContext, path); } }