mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Fixed 74328 - [Scanner][IProblem] char * initialization problem
This commit is contained in:
parent
14bbb07c98
commit
bea93881a3
5 changed files with 25 additions and 18 deletions
|
@ -2110,7 +2110,18 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
writer.write( "using namespace N; \n" );
|
||||
writer.write( "PINT pint; \n" );
|
||||
parse( writer.toString() );
|
||||
assertTrue( callback.problems.isEmpty() );
|
||||
}
|
||||
|
||||
public void testBug74328() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "int\n" );
|
||||
writer.write( "main(int argc, char **argv) {\n" );
|
||||
writer.write( " char *sign;\n" );
|
||||
writer.write( "sign = \"\"; // IProblem generated here, syntax error\n" );
|
||||
writer.write( "return argc;\n" );
|
||||
writer.write( "}\n" );
|
||||
parse( writer.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1851,4 +1851,12 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
assertEquals( t.getOffset(), offset + 3 );
|
||||
assertEquals( t.getLineNumber(), 2 );
|
||||
}
|
||||
|
||||
public void testBug74328() throws Exception
|
||||
{
|
||||
initializeScanner( "\"\";\n" ); //$NON-NLS-1$
|
||||
validateString( ""); //$NON-NLS-1$
|
||||
validateToken( IToken.tSEMI );
|
||||
validateEOF();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,5 @@ public interface IASTSimpleTypeSpecifier extends IASTTypeSpecifier
|
|||
public boolean isImaginary();
|
||||
|
||||
public IASTTypeSpecifier getTypeSpecifier() throws ASTNotImplementedException;
|
||||
/**
|
||||
* @param referenceManager
|
||||
*/
|
||||
public void releaseReferences();
|
||||
|
||||
}
|
||||
|
|
|
@ -4035,9 +4035,6 @@ public class Parser implements IParserData, IParser
|
|||
((IASTOffsetableElement)declaration).setEndingOffsetAndLineNumber(
|
||||
lastToken.getEndOffset(), lastToken.getLineNumber());
|
||||
declaration.acceptElement( requestor );
|
||||
if( sdw.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
|
||||
((IASTSimpleTypeSpecifier)sdw.getTypeSpecifier()).releaseReferences( );
|
||||
|
||||
}
|
||||
return declaration;
|
||||
}
|
||||
|
@ -4045,10 +4042,7 @@ public class Parser implements IParserData, IParser
|
|||
endDeclaration( declaration );
|
||||
declaration.enterScope( requestor );
|
||||
try
|
||||
{
|
||||
if( sdw.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
|
||||
((IASTSimpleTypeSpecifier)sdw.getTypeSpecifier()).releaseReferences( );
|
||||
|
||||
{
|
||||
if ( !( declaration instanceof IASTScope ) )
|
||||
throwBacktrack(firstOffset, endOffset, firstLine, fn);
|
||||
|
||||
|
@ -4092,15 +4086,11 @@ public class Parser implements IParserData, IParser
|
|||
return null;
|
||||
} catch( BacktrackException be )
|
||||
{
|
||||
if( simpleTypeSpecifier != null )
|
||||
simpleTypeSpecifier.releaseReferences();
|
||||
throwBacktrack(be);
|
||||
return null;
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
if( simpleTypeSpecifier != null )
|
||||
simpleTypeSpecifier.releaseReferences();
|
||||
throw eof;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -865,8 +865,9 @@ public class Scanner2 implements IScanner, IScannerData {
|
|||
return new ImagedExpansionToken( signal, buffer, bufferPos[mostRelevant], ((IMacro)bufferData[bufferStackPos]).getName().length, getCurrentFilename(), getLineNumber( bufferPos[mostRelevant] + 1));
|
||||
}
|
||||
IToken i = new ImagedToken(signal, buffer, bufferPos[bufferStackPos] + 1 , getCurrentFilename(), getLineNumber( bufferPos[bufferStackPos] + 1));
|
||||
if( buffer != null && buffer.length == 0 )
|
||||
bufferPos[bufferStackPos] += 1; //ensure we don't hit infinite loops
|
||||
if( buffer != null && buffer.length == 0 && signal != IToken.tSTRING && signal != IToken.tLSTRING )
|
||||
bufferPos[bufferStackPos] += 1; //TODO - remove this hack at some point
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue