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:
parent
35a78ba53d
commit
100c6ff5d2
4 changed files with 57 additions and 42 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,55 +33,58 @@ 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 ) {
|
|
||||||
super( node, id, arg );
|
public CPPBaseProblem(IASTNode node, int id, char[] 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);
|
||||||
}
|
}
|
||||||
return classProblem;
|
return classProblem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
*/
|
*/
|
||||||
public IBinding getBaseClass() throws DOMException {
|
public IBinding getBaseClass() throws DOMException {
|
||||||
if( baseClass == null ){
|
if (baseClass == null) {
|
||||||
IBinding b = base.getName().resolveBinding();
|
IBinding b = base.getName().resolveBinding();
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return baseClass;
|
return baseClass;
|
||||||
|
@ -93,10 +96,10 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
||||||
public int getVisibility() {
|
public int getVisibility() {
|
||||||
int vis = base.getVisibility();
|
int vis = base.getVisibility();
|
||||||
|
|
||||||
if( vis == 0 ){
|
if (vis == 0) {
|
||||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) base.getParent();
|
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) base.getParent();
|
||||||
int key = compSpec.getKey();
|
int key = compSpec.getKey();
|
||||||
if( key == ICPPClassType.k_class )
|
if (key == ICPPClassType.k_class)
|
||||||
vis = ICPPBase.v_private;
|
vis = ICPPBase.v_private;
|
||||||
else
|
else
|
||||||
vis = ICPPBase.v_public;
|
vis = ICPPBase.v_public;
|
||||||
|
@ -120,11 +123,11 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone(){
|
public Object clone() {
|
||||||
ICPPBase t = null;
|
ICPPBase t = null;
|
||||||
try {
|
try {
|
||||||
t = (ICPPBase) super.clone();
|
t = (ICPPBase) super.clone();
|
||||||
} catch ( CloneNotSupportedException e ) {
|
} catch (CloneNotSupportedException e) {
|
||||||
//not going to happen
|
//not going to happen
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
||||||
|
@ -1766,20 +1769,21 @@ public class CPPVisitor {
|
||||||
IBinding binding = resolveBinding(expression);
|
IBinding binding = resolveBinding(expression);
|
||||||
try {
|
try {
|
||||||
if (binding instanceof IVariable) {
|
if (binding instanceof IVariable) {
|
||||||
return ((IVariable)binding).getType();
|
return ((IVariable) binding).getType();
|
||||||
} else if (binding instanceof IEnumerator) {
|
} else if (binding instanceof IEnumerator) {
|
||||||
return ((IEnumerator)binding).getType();
|
return ((IEnumerator) binding).getType();
|
||||||
} else if (binding instanceof IProblemBinding) {
|
} else if (binding instanceof IProblemBinding) {
|
||||||
return (IType) binding;
|
return (IType) binding;
|
||||||
} else if (binding instanceof IFunction) {
|
} else if (binding instanceof IFunction) {
|
||||||
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());
|
||||||
|
@ -2198,22 +2202,22 @@ public class CPPVisitor {
|
||||||
* @return whether the specified expression is an rvalue
|
* @return whether the specified expression is an rvalue
|
||||||
*/
|
*/
|
||||||
static boolean isRValue(IASTExpression exp) {
|
static boolean isRValue(IASTExpression exp) {
|
||||||
if(exp instanceof IASTUnaryExpression) {
|
if (exp instanceof IASTUnaryExpression) {
|
||||||
IASTUnaryExpression ue= (IASTUnaryExpression) exp;
|
IASTUnaryExpression ue= (IASTUnaryExpression) exp;
|
||||||
if(ue.getOperator() == IASTUnaryExpression.op_amper) {
|
if (ue.getOperator() == IASTUnaryExpression.op_amper) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(exp instanceof IASTLiteralExpression)
|
if (exp instanceof IASTLiteralExpression)
|
||||||
return true;
|
return true;
|
||||||
if(exp instanceof IASTFunctionCallExpression) {
|
if (exp instanceof IASTFunctionCallExpression) {
|
||||||
try {
|
try {
|
||||||
IASTFunctionCallExpression fc= (IASTFunctionCallExpression) exp;
|
IASTFunctionCallExpression fc= (IASTFunctionCallExpression) exp;
|
||||||
IASTExpression fne= fc.getFunctionNameExpression();
|
IASTExpression fne= fc.getFunctionNameExpression();
|
||||||
if(fne instanceof IASTIdExpression) {
|
if (fne instanceof IASTIdExpression) {
|
||||||
IASTIdExpression ide= (IASTIdExpression) fne;
|
IASTIdExpression ide= (IASTIdExpression) fne;
|
||||||
IBinding b= ide.getName().resolveBinding();
|
IBinding b= ide.getName().resolveBinding();
|
||||||
if(b instanceof IFunction) {
|
if (b instanceof IFunction) {
|
||||||
IFunctionType tp= ((IFunction)b).getType();
|
IFunctionType tp= ((IFunction)b).getType();
|
||||||
return !(tp.getReturnType() instanceof ICPPReferenceType);
|
return !(tp.getReturnType() instanceof ICPPReferenceType);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue