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:
parent
3fa54b37ea
commit
e62982abd7
2 changed files with 21 additions and 0 deletions
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue