1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for bug 232086.

This commit is contained in:
Sergey Prigogin 2008-05-19 07:54:36 +00:00
parent 35a78ba53d
commit 100c6ff5d2
4 changed files with 57 additions and 42 deletions

View file

@ -2082,7 +2082,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// void f(C<char>& str) { // void f(C<char>& str) {
// str.m(); // str.m();
// } // }
public void _testBug232086() throws Exception { public void testBug232086() throws Exception {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
ICPPFunction b0 = bh.assertNonProblem("m();", 1, ICPPFunction.class); ICPPFunction b0 = bh.assertNonProblem("m();", 1, ICPPFunction.class);
} }

View file

@ -33,10 +33,12 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
*/ */
public class CPPBaseClause implements ICPPBase, ICPPInternalBase { public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
static public class CPPBaseProblem extends ProblemBinding implements ICPPBase, ICPPInternalBase { static public class CPPBaseProblem extends ProblemBinding implements ICPPBase, ICPPInternalBase {
private ICPPClassType classProblem = null; private ICPPClassType classProblem;
public CPPBaseProblem(IASTNode node, int id, char[] arg) { public CPPBaseProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg); super(node, id, arg);
} }
public IBinding getBaseClass() { public IBinding getBaseClass() {
if (classProblem == null) { if (classProblem == null) {
classProblem = new CPPClassType.CPPClassTypeProblem(node, id, arg); classProblem = new CPPClassType.CPPClassTypeProblem(node, id, arg);
@ -51,21 +53,23 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
public boolean isVirtual() throws DOMException { public boolean isVirtual() throws DOMException {
throw new DOMException(this); throw new DOMException(this);
} }
public IName getBaseClassSpecifierName() { public IName getBaseClassSpecifierName() {
return (IName) node; return (IName) node;
} }
public void setBaseClass(IBinding binding) throws DOMException { public void setBaseClass(IBinding binding) throws DOMException {
throw new DOMException(this); throw new DOMException(this);
} }
} }
private ICPPASTBaseSpecifier base = null;
private IBinding baseClass = null; private ICPPASTBaseSpecifier base;
private IBinding baseClass;
public CPPBaseClause(ICPPASTBaseSpecifier base) { public CPPBaseClause(ICPPASTBaseSpecifier base) {
this.base = base; this.base = base;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getBaseClass() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getBaseClass()
*/ */
@ -75,10 +79,9 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
while (b instanceof ITypedef && ((ITypedef) b).getType() instanceof IBinding) { while (b instanceof ITypedef && ((ITypedef) b).getType() instanceof IBinding) {
b = (IBinding) ((ITypedef) b).getType(); b = (IBinding) ((ITypedef) b).getType();
} }
if( b instanceof ICPPClassType || b instanceof ICPPTemplateParameter ) if (b instanceof ICPPClassType || b instanceof ICPPTemplateParameter) {
baseClass = b; baseClass = b;
} else if (b instanceof IProblemBinding) {
else if( b instanceof IProblemBinding ){
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID(), base.getName().toCharArray()); baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID(), base.getName().toCharArray());
} else { } else {
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND, base.getName().toCharArray()); baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND, base.getName().toCharArray());

View file

@ -8,10 +8,12 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
@ -36,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* @author aniefer * @author aniefer
@ -43,9 +46,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPUnknownBinding { ICPPTemplateTemplateParameter, ICPPClassType, ICPPInternalTemplate, ICPPUnknownBinding {
private ICPPTemplateParameter[] templateParameters = null; private ICPPTemplateParameter[] templateParameters;
private ObjectMap instances = null; private ObjectMap instances;
private ICPPScope unknownScope = null; private ICPPScope unknownScope;
/** /**
* @param name * @param name
@ -65,7 +68,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return unknownScope; return unknownScope;
} }
public ICPPTemplateParameter[] getTemplateParameters() { public ICPPTemplateParameter[] getTemplateParameters() {
if (templateParameters == null) { if (templateParameters == null) {
ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent(); ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent();
@ -90,7 +92,6 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return templateParameters; return templateParameters;
} }
public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) { public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) {
IASTName name = CPPTemplates.getTemplateParameterName(templateParameter); IASTName name = CPPTemplates.getTemplateParameterName(templateParameter);
@ -108,12 +109,19 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return binding; return binding;
} }
public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException {
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
} }
public IType getDefault() throws DOMException { public IType getDefault() throws DOMException {
IASTNode[] nds = getDeclarations();
if (nds == null || nds.length == 0)
return null;
IASTName name = (IASTName) nds[0];
ICPPASTTemplatedTypeTemplateParameter param = (ICPPASTTemplatedTypeTemplateParameter) name.getParent();
IASTExpression defaultValue = param.getDefaultValue();
if (defaultValue != null)
return CPPVisitor.createType(defaultValue);
return null; return null;
} }

View file

@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
@ -725,6 +726,7 @@ public class CPPVisitor {
} }
return isConstructor(clsName, declarator); return isConstructor(clsName, declarator);
} }
public static boolean isConstructor(IASTName parentName, IASTDeclarator declarator) { public static boolean isConstructor(IASTName parentName, IASTDeclarator declarator) {
if (declarator == null || !(declarator instanceof IASTFunctionDeclarator)) if (declarator == null || !(declarator instanceof IASTFunctionDeclarator))
return false; return false;
@ -1607,6 +1609,7 @@ public class CPPVisitor {
} }
return type; return type;
} }
private static IType getArrayTypes(IType type, IASTArrayDeclarator declarator) { private static IType getArrayTypes(IType type, IASTArrayDeclarator declarator) {
IASTArrayModifier[] mods = declarator.getArrayModifiers(); IASTArrayModifier[] mods = declarator.getArrayModifiers();
for (IASTArrayModifier mod : mods) { for (IASTArrayModifier mod : mods) {
@ -1775,11 +1778,12 @@ public class CPPVisitor {
return ((IFunction) binding).getType(); return ((IFunction) binding).getType();
} else if (binding instanceof ICPPTemplateNonTypeParameter) { } else if (binding instanceof ICPPTemplateNonTypeParameter) {
return ((ICPPTemplateNonTypeParameter) binding).getType(); return ((ICPPTemplateNonTypeParameter) binding).getType();
} else if (binding instanceof ICPPClassType) {
return ((ICPPClassType) binding);
} }
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
} else if (expression instanceof IASTCastExpression) { } else if (expression instanceof IASTCastExpression) {
IASTTypeId id = ((IASTCastExpression)expression).getTypeId(); IASTTypeId id = ((IASTCastExpression)expression).getTypeId();
IType type = createType(id.getDeclSpecifier()); IType type = createType(id.getDeclSpecifier());