diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java index 510f4ba4c7c..2a7b04db704 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; +import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; /** * @author jcamelon @@ -109,8 +110,8 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId { * @see org.eclipse.cdt.core.dom.ast.IASTName#resolveBinding() */ public IBinding resolveBinding() { - // TODO Auto-generated method stub - return null; + // TODO templates not yet supported + return new ProblemBinding( -1, templateName.toCharArray() ); } public IBinding[] resolvePrefix() { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java index 3bb1a7a48ac..d1c75d88696 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java @@ -180,7 +180,7 @@ public class CPPImplicitMethod extends CPPMethod { IType [] ps = t.getParameterTypes(); if( ps.length == params.length ){ int idx = 0; - for( ; idx < ps.length; idx++ ){ + for( ; idx < ps.length && ps[idx] != null; idx++ ){ if( !ps[idx].equals(params[idx]) ) break; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java index 4863914261b..81f460327e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java @@ -47,6 +47,9 @@ public class CPPPointerType implements IPointerType, ITypeContainer { if( !( o instanceof CPPPointerType ) ) return false; + if( type == null ) + return false; + CPPPointerType pt = (CPPPointerType) o; if( isConst() == pt.isConst() && isVolatile() == pt.isVolatile() ) return type.equals( pt.getType() ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java index 0986c3ba67e..d85b841bafc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java @@ -431,9 +431,11 @@ public class CPPSemantics { ICPPClassType cls = (ICPPClassType) binding; try { //force resolution of constructor bindings - cls.getConstructors(); - //then use the class scope to resolve which one. - binding = ((ICPPClassScope)cls.getCompositeScope()).getBinding( data.astName ); + IBinding [] ctors = cls.getConstructors(); + if( ctors.length > 0 && !(ctors[0] instanceof IProblemBinding) ){ + //then use the class scope to resolve which one. + binding = ((ICPPClassScope)cls.getCompositeScope()).getBinding( data.astName ); + } } catch ( DOMException e ) { binding = e.getProblem(); } @@ -1527,14 +1529,17 @@ public class CPPSemantics { cost.rank = Cost.IDENTITY_RANK; //exact match, no cost } else { cost = checkStandardConversionSequence( source, target ); - - //12.3-4 At most one user-defined conversion is implicitly applied to - //a single value. (also prevents infinite loop) - if( cost.rank == Cost.NO_MATCH_RANK && !data.forUserDefinedConversion ){ - temp = checkUserDefinedConversionSequence( source, target ); - if( temp != null ){ - cost = temp; + if( !data.forDefinition() ){ + //12.3-4 At most one user-defined conversion is implicitly applied to + //a single value. (also prevents infinite loop) + if( cost.rank == Cost.NO_MATCH_RANK && !data.forUserDefinedConversion ){ + temp = checkUserDefinedConversionSequence( source, target ); + if( temp != null ){ + cost = temp; + } } + } else { + cost.rank = Cost.NO_MATCH_RANK; } } @@ -1829,6 +1834,12 @@ public class CPPSemantics { //was the qualification conversion enough? IType s = getUltimateType( cost.source, true ); IType t = getUltimateType( cost.target, true ); + + if( s == null || t == null ){ + cost.rank = Cost.NO_MATCH_RANK; + return cost; + } + if( s.equals( t ) ){ return cost; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java index 9f736fac635..a621bee2d84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java @@ -54,9 +54,14 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding { } public boolean equals( Object o ){ + if( o == this ) + return true; if( o instanceof ITypedef ) try { - return getType().equals( ((ITypedef)o).getType()); + IType t = getType(); + if( t != null ) + return t.equals( ((ITypedef)o).getType()); + return false; } catch ( DOMException e ) { return false; } @@ -64,7 +69,10 @@ public class CPPTypedef implements ITypedef, ITypeContainer, ICPPBinding { if( !( o instanceof IType ) ) return false; - return getType().equals( o ); + IType t = getType(); + if( t != null ) + return t.equals( o ); + return false; } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java index d6da541d856..82bd841ae4e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVariable.java @@ -49,12 +49,13 @@ public class CPPVariable implements IVariable, ICPPBinding { private IType type = null; public CPPVariable( IASTName name ){ + boolean isDef = isDefinition( name ); if( name instanceof ICPPASTQualifiedName ){ IASTName [] ns = ((ICPPASTQualifiedName)name).getNames(); name = ns[ ns.length - 1 ]; } - if( isDefinition( name ) ) + if( isDef ) definition = name; else declarations = new IASTName [] { name }; @@ -62,6 +63,13 @@ public class CPPVariable implements IVariable, ICPPBinding { } protected boolean isDefinition( IASTName name ){ + IASTNode node = name.getParent(); + if( node instanceof ICPPASTQualifiedName ) + node = node.getParent(); + + if( !( node instanceof IASTDeclarator ) ) + return false; + IASTDeclarator dtor = (IASTDeclarator) name.getParent(); while( dtor.getParent() instanceof IASTDeclarator ) dtor = (IASTDeclarator) dtor.getParent(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index 394cbec2810..f828a38c181 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -548,7 +548,10 @@ public class CPPVisitor implements ICPPASTVisitor { else if( prop == IASTFunctionDefinition.DECLARATOR ) return ((IASTCompoundStatement)((IASTFunctionDefinition)dtor.getParent()).getBody()).getScope(); } else if( node instanceof IASTInitializerExpression ){ - IASTDeclarator dtor = (IASTDeclarator) node.getParent(); + IASTNode parent = node.getParent(); + while( !(parent instanceof IASTDeclarator) ) + parent = parent.getParent(); + IASTDeclarator dtor = (IASTDeclarator) parent; IASTName name = dtor.getName(); if( name instanceof ICPPASTQualifiedName ){ IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();