mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix parsing of unary ampersand cast on an expression result
This commit is contained in:
parent
4729acab03
commit
dbcc3f2792
2 changed files with 26 additions and 3 deletions
|
@ -1176,7 +1176,9 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
IASTClassSpecifier A = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
assertEquals( A.getName(), "A"); //$NON-NLS-1$
|
||||
IASTVariable anotherA = (IASTVariable)i.next();
|
||||
assertEquals( anotherA.getName(), "b"); //$NON-NLS-1$
|
||||
assertEquals( anotherA.getName(), "anotherA"); //$NON-NLS-1$
|
||||
IASTVariable b = (IASTVariable)i.next();
|
||||
assertEquals( b.getName(), "b"); //$NON-NLS-1$
|
||||
assertFalse(i.hasNext()); // should be true
|
||||
}
|
||||
|
||||
|
@ -1969,5 +1971,24 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
IASTTypeId typeId = v.getInitializerClause().getAssigmentExpression().getTypeId();
|
||||
assertEquals( typeId.getFullSignature(), "int *"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testUnaryAmperCast() throws Exception{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "void f( char * ); \n ");
|
||||
writer.write( "void f( char ); \n ");
|
||||
writer.write( "void main() { \n ");
|
||||
writer.write( " char * t = new char [ 5 ]; \n ");
|
||||
writer.write( " f( &t[1] ); \n ");
|
||||
writer.write( "} \n ");
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
IASTFunction f1 = (IASTFunction) i.next();
|
||||
IASTFunction f2 = (IASTFunction) i.next();
|
||||
|
||||
IASTFunction main = (IASTFunction) i.next();
|
||||
IASTVariable t = (IASTVariable) getDeclarations( main ).next();
|
||||
|
||||
assertAllReferences( 2, createTaskList( new Task( f1, 1, false, false), new Task( t ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1613,8 +1613,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
|
||||
|
||||
info = left.getResultType().getResult();
|
||||
if ((info != null) && (info.getTypeSymbol() != null)){
|
||||
if (info != null){
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
|
||||
info = info.getFinalType( null );
|
||||
} else
|
||||
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
|
||||
|
||||
|
@ -1628,8 +1629,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if(left == null)
|
||||
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
|
||||
info = left.getResultType().getResult();
|
||||
if ((info != null)&& (info.getTypeSymbol() != null)){
|
||||
if (info != null){
|
||||
info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
|
||||
info = info.getFinalType( null );
|
||||
}else
|
||||
handleProblem( scope, IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue