1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

fix bug 95461 (array to pointer conversion)

This commit is contained in:
Andrew Niefer 2005-05-16 21:39:46 +00:00
parent 3fa54b37ea
commit e62982abd7
2 changed files with 21 additions and 0 deletions

View file

@ -4068,4 +4068,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals( ctors.length, 2 );
assertSame( ctor, ctors[0] );
}
public void testBug95461() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("void f( char * ); \n"); //$NON-NLS-1$
buffer.append("void g(){ \n"); //$NON-NLS-1$
buffer.append(" char x[100]; \n"); //$NON-NLS-1$
buffer.append(" f( x ); \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
ICPPFunction f1 = (ICPPFunction) col.getName(0).resolveBinding();
assertSame( f1, col.getName(4).resolveBinding() );
}
}

View file

@ -45,6 +45,7 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.IArrayType;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -2525,6 +2526,10 @@ public class CPPSemantics {
{
source = new CPPPointerType( source );
}
//4.2 Array-To-Pointer conversion
else if( target instanceof IPointerType && source instanceof IArrayType ){
source = new CPPPointerType( ((IArrayType)source).getType() );
}
cost.source = source;
cost.target = target;