mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
7d0db41463
commit
34f1154c4f
5 changed files with 50 additions and 26 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-04-22 John Camelon
|
||||||
|
Added CompleteParseASTTest:testBug47926().
|
||||||
|
|
||||||
2004-04-22 John Camelon
|
2004-04-22 John Camelon
|
||||||
Updated test clients for IExpressionParser interface changes.
|
Updated test clients for IExpressionParser interface changes.
|
||||||
Added QuickParseASTTests.testBug59179().
|
Added QuickParseASTTests.testBug59179().
|
||||||
|
|
|
@ -137,27 +137,4 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
|
||||||
// assertFalse( i.hasNext() );
|
// assertFalse( i.hasNext() );
|
||||||
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
|
// 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 ) ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1645,4 +1645,16 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 )));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
2004-04-22 John Camelon
|
||||||
Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=59686
|
Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=59686
|
||||||
|
|
||||||
|
|
|
@ -1057,6 +1057,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
// Try to figure out the result that this expression evaluates to
|
// Try to figure out the result that this expression evaluates to
|
||||||
ExpressionResult expressionResult = getExpressionResultType(scope, kind, lhs, rhs, thirdExpression, typeId, literal, symbol);
|
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
|
// expression results could be empty, but should not be null
|
||||||
// assert expressionResult != null : expressionResult; //throw new ASTSemanticException();
|
// assert expressionResult != null : expressionResult; //throw new ASTSemanticException();
|
||||||
|
|
||||||
|
@ -1069,6 +1073,31 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
|
|
||||||
return expression;
|
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
|
* Try and dereference the symbol in the expression
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue