1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
John Camelon 2004-05-17 23:26:39 +00:00
parent 0ea66906c5
commit 591d1d3a21
2 changed files with 40 additions and 2 deletions

View file

@ -1584,4 +1584,36 @@ public class ScannerTestCase extends BaseScannerTest
initializeScanner( "18446744073709551615LL"); //$NON-NLS-1$ initializeScanner( "18446744073709551615LL"); //$NON-NLS-1$
validateInteger( "18446744073709551615"); //$NON-NLS-1$ validateInteger( "18446744073709551615"); //$NON-NLS-1$
} }
public void testBug62390() throws Exception
{
Writer writer = new StringWriter();
writer.write( "#define f(x) x\n"); //$NON-NLS-1$
writer.write( "#if f(\n"); //$NON-NLS-1$
writer.write( "5) == 5\n"); //$NON-NLS-1$
writer.write( "true1\n"); //$NON-NLS-1$
writer.write( "#endif\n"); //$NON-NLS-1$
writer.write( "#if A\n"); //$NON-NLS-1$
writer.write( "#elif f(\n"); //$NON-NLS-1$
writer.write( "5) == 5\n"); //$NON-NLS-1$
writer.write( "true2\n"); //$NON-NLS-1$
writer.write( "#endif\n"); //$NON-NLS-1$
writer.write( "#undef f\n"); //$NON-NLS-1$
writer.write( "#define f(x) \"A0I70_001.h\"\n"); //$NON-NLS-1$
writer.write( "#include f(\n"); //$NON-NLS-1$
writer.write( "5\n"); //$NON-NLS-1$
writer.write( ")\n"); //$NON-NLS-1$
writer.write( "#undef f\n"); //$NON-NLS-1$
writer.write( "#define f(x) 1467\n"); //$NON-NLS-1$
writer.write( "#line f(\n"); //$NON-NLS-1$
writer.write( "5\n"); //$NON-NLS-1$
writer.write( ")\n"); //$NON-NLS-1$
writer.write( "#pragma f(\n"); //$NON-NLS-1$
writer.write( "5\n"); //$NON-NLS-1$
writer.write( ")\n"); //$NON-NLS-1$
writer.write( "}\n"); //$NON-NLS-1$
Callback callback = new Callback( ParserMode.QUICK_PARSE );
initializeScanner( writer.toString(), ParserMode.QUICK_PARSE, callback );
fullyTokenize();
}
} }

View file

@ -204,7 +204,9 @@ public class ContextStack {
public ScannerContextInclusion getMostRelevantFileContext() public ScannerContextInclusion getMostRelevantFileContext()
{ {
return (ScannerContextInclusion)cs[lastFileContext]; if( cs[lastFileContext] != null && cs[lastFileContext] instanceof ScannerContextInclusion )
return (ScannerContextInclusion)cs[lastFileContext];
return null;
} }
public int getMostRelevantFileContextIndex() public int getMostRelevantFileContextIndex()
@ -213,7 +215,11 @@ public class ContextStack {
} }
public int getCurrentLineNumber() public int getCurrentLineNumber()
{ {
return getMostRelevantFileContext().getLine();
ScannerContextInclusion mostRelevantFileContext = getMostRelevantFileContext();
if( mostRelevantFileContext != null )
return mostRelevantFileContext.getLine();
return -1;
} }
} }