diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java index 2ccc3a12c82..9a5ced55dec 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java @@ -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 ) ) ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java index 11eab183308..b4eab4c49e2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java @@ -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 );