1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
John Camelon 2004-04-23 03:49:31 +00:00
parent 7d0db41463
commit 34f1154c4f
5 changed files with 50 additions and 26 deletions

View file

@ -1,3 +1,6 @@
2004-04-22 John Camelon
Added CompleteParseASTTest:testBug47926().
2004-04-22 John Camelon
Updated test clients for IExpressionParser interface changes.
Added QuickParseASTTests.testBug59179().

View file

@ -136,28 +136,5 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
// IASTVariable x = (IASTVariable) i.next();
// assertFalse( i.hasNext() );
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
}
public void testBug47926() throws Exception{
StringBuffer buffer = new StringBuffer();
buffer.append( "void f () {} \n" );
buffer.append( "class A { }; \n" );
buffer.append( "void main() { A * a = new A(); a->f(); } ");
Iterator i = parse( buffer.toString() ).getDeclarations();
IASTFunction f = (IASTFunction) i.next();
IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
IASTFunction main = (IASTFunction) i.next();
Iterator fnIter = getDeclarations( main );
IASTVariable a = (IASTVariable) fnIter.next();
//there should be no reference to f, but there is
//assertAllReferences( 3, createTaskList( new Task( classA, 2 ), new Task( a ) ) );
assertAllReferences( 4, createTaskList( new Task( classA, 2 ), new Task( a ), new Task( f ) ) );
}
}
}

View file

@ -1644,5 +1644,17 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertFalse( i.hasNext() );
}
public void testBug47926() throws Exception
{
Iterator i = parse( "void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false ).getDeclarations();
IASTFunction f = (IASTFunction) i.next();
IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next() ).getTypeSpecifier();
IASTFunction main = (IASTFunction) i.next();
assertFalse( i.hasNext() );
i = getDeclarations( main );
IASTVariable a = (IASTVariable) i.next();
assertAllReferences( 3, createTaskList( new Task( A, 2 ), new Task( a )));
}
}

View file

@ -1,3 +1,6 @@
2004-04-22 John Camelon
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=47926
2004-04-22 John Camelon
Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=59686

View file

@ -1056,7 +1056,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
// Try to figure out the result that this expression evaluates to
ExpressionResult expressionResult = getExpressionResultType(scope, kind, lhs, rhs, thirdExpression, typeId, literal, symbol);
if( symbol == null )
purgeBadReferences( kind, rhs );
// expression results could be empty, but should not be null
// assert expressionResult != null : expressionResult; //throw new ASTSemanticException();
@ -1069,7 +1073,32 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return expression;
}
/*
/**
* @param kind
* @param rhs
*/
private void purgeBadReferences(Kind kind, IASTExpression rhs) {
if( rhs == null ) return;
if( kind == Kind.POSTFIX_ARROW_IDEXPRESSION || kind == Kind.POSTFIX_ARROW_TEMPL_IDEXP ||
kind == Kind.POSTFIX_DOT_IDEXPRESSION || kind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS )
{
ASTExpression astExpression = (ASTExpression) rhs;
Iterator refs = astExpression.getReferences().iterator();
String idExpression = astExpression.getIdExpression();
if( !idExpression.equals( ""))
{
while( refs.hasNext() )
{
IASTReference r = (IASTReference) refs.next();
if( r.getName().equals( idExpression ) )
refs.remove();
}
}
}
}
/*
* Try and dereference the symbol in the expression
*/
private ISymbol getExpressionSymbol(