mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
0ea66906c5
commit
591d1d3a21
2 changed files with 40 additions and 2 deletions
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,9 @@ public class ContextStack {
|
||||||
|
|
||||||
public ScannerContextInclusion getMostRelevantFileContext()
|
public ScannerContextInclusion getMostRelevantFileContext()
|
||||||
{
|
{
|
||||||
|
if( cs[lastFileContext] != null && cs[lastFileContext] instanceof ScannerContextInclusion )
|
||||||
return (ScannerContextInclusion)cs[lastFileContext];
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue