1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
John Camelon 2004-06-23 18:24:41 +00:00
parent 17e970b3a6
commit 3783f1b7be
3 changed files with 36 additions and 6 deletions

View file

@ -801,8 +801,10 @@ public class CompleteParseBaseTest extends TestCase
ParserFactory.createScanner( new CodeReader( code.toCharArray() ), new ScannerInfo(), //$NON-NLS-1$
ParserMode.COMPLETE_PARSE, language, callback, new NullLogService(), null ), callback, ParserMode.COMPLETE_PARSE, language, null
);
if( ! parser.parse() && throwOnError ) throw new ParserException( "FAILURE"); //$NON-NLS-1$
assertTrue( ((CompleteParser)parser).validateCaches());
boolean parseResult = parser.parse();
if( ! parseResult && throwOnError ) throw new ParserException( "FAILURE"); //$NON-NLS-1$
if( parseResult )
assertTrue( ((CompleteParser)parser).validateCaches());
return callback.getCompilationUnit();
}

View file

@ -58,8 +58,21 @@ public class CompleteParseProblemTest extends CompleteParseBaseTest {
assertEquals( p.getID(), IProblem.SYNTAX_ERROR );
assertEquals( p.getSourceStart(), code.indexOf( name )); //$NON-NLS-1$
assertEquals( p.getSourceEnd(), code.indexOf( name ) + name.length() ); //$NON-NLS-1$
}
public void testBug68306() throws Exception
{
StringBuffer buffer = new StringBuffer();
buffer.append( "class Foo { int bar( int ); };\n" ); //$NON-NLS-1$
buffer.append( "int Foo::bar( int ){}\n" ); //$NON-NLS-1$
buffer.append( "int Foo::bar( int ){} //error\n" ); //$NON-NLS-1$
String code = buffer.toString();
parse( code, false );
assertFalse( callback.problems.isEmpty() );
assertEquals( callback.problems.size(), 1 );
IProblem p = (IProblem) callback.problems.get( 0 );
assertTrue( p.checkCategory( IProblem.SEMANTICS_RELATED ));
}
}

View file

@ -881,6 +881,8 @@ public abstract class Parser extends ExpressionParser implements IParser
throws EndOfFileException, BacktrackException
{
simpleDeclarationMark = mark();
IProblem firstFailure = null;
IProblem secondFailure = null;
try
{
return simpleDeclaration(
@ -893,6 +895,7 @@ public abstract class Parser extends ExpressionParser implements IParser
{
if( simpleDeclarationMark == null )
throwBacktrack( bt );
firstFailure = bt.getProblem();
// did not work
backup(simpleDeclarationMark);
@ -906,8 +909,14 @@ public abstract class Parser extends ExpressionParser implements IParser
catch( BacktrackException bt2 )
{
if( simpleDeclarationMark == null )
throwBacktrack(bt2);
{
if( firstFailure != null && (bt2.getProblem() == null ))
throwBacktrack(firstFailure);
else
throwBacktrack(bt2);
}
secondFailure = bt2.getProblem();
backup( simpleDeclarationMark );
try
@ -920,7 +929,13 @@ public abstract class Parser extends ExpressionParser implements IParser
catch( BacktrackException b3 )
{
backup( simpleDeclarationMark ); //TODO - necessary?
throwBacktrack( b3 );
if( firstFailure != null )
throwBacktrack( firstFailure );
else if( secondFailure != null )
throwBacktrack( secondFailure );
else
throwBacktrack( b3 );
return null;
}
}