mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 299911. Fixed remaining failing tests.
This commit is contained in:
parent
e5c9fc3ee6
commit
765363be4a
5 changed files with 52 additions and 70 deletions
|
@ -5747,7 +5747,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
// g<C>(0); // The N member of C is not a non-type
|
// g<C>(0); // The N member of C is not a non-type
|
||||||
// h<D>(0); // The TT member of D is not a template
|
// h<D>(0); // The TT member of D is not a template
|
||||||
// }
|
// }
|
||||||
public void _test14_8_2s8d() throws Exception {
|
public void test14_8_2s8d() throws Exception {
|
||||||
final String content= getAboveComment();
|
final String content= getAboveComment();
|
||||||
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
|
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
|
||||||
bh.assertProblem("f<A>", 0);
|
bh.assertProblem("f<A>", 0);
|
||||||
|
|
|
@ -4404,7 +4404,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
assertEquals("void (#0 (* ...)())", ASTTypeUtil.getType(f.getType(), true));
|
assertEquals("void (#0 (* ...)())", ASTTypeUtil.getType(f.getType(), true));
|
||||||
assertTrue(f.getParameters()[0].isParameterPack());
|
assertTrue(f.getParameters()[0].isParameterPack());
|
||||||
f= bh.assertNonProblem("f4", 2);
|
f= bh.assertNonProblem("f4", 2);
|
||||||
assertEquals("void (int (& ...)[`0])", ASTTypeUtil.getType(f.getType(), true));
|
assertEquals("void (int (& ...)[3 *0 0])", ASTTypeUtil.getType(f.getType(), true));
|
||||||
assertTrue(f.getParameters()[0].isParameterPack());
|
assertTrue(f.getParameters()[0].isParameterPack());
|
||||||
f= bh.assertNonProblem("f5", 2);
|
f= bh.assertNonProblem("f5", 2);
|
||||||
assertEquals("void (#0 ...)", ASTTypeUtil.getType(f.getType(), true));
|
assertEquals("void (#0 ...)", ASTTypeUtil.getType(f.getType(), true));
|
||||||
|
|
|
@ -184,7 +184,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
||||||
@Override
|
@Override
|
||||||
public IBinding[] getBindings(ScopeLookupData lookup) {
|
public IBinding[] getBindings(ScopeLookupData lookup) {
|
||||||
IBinding[] result = getBindingsInAST(lookup);
|
IBinding[] result = getBindingsInAST(lookup);
|
||||||
final IASTTranslationUnit tu = lookup.getLookupPoint().getTranslationUnit();
|
final IASTTranslationUnit tu = lookup.getTranslationUnit();
|
||||||
if (tu != null) {
|
if (tu != null) {
|
||||||
IIndex index = tu.getIndex();
|
IIndex index = tu.getIndex();
|
||||||
if (index != null) {
|
if (index != null) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||||
|
@ -29,11 +30,8 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
private static class SignatureBuilder implements ITypeMarshalBuffer {
|
private static class SignatureBuilder implements ITypeMarshalBuffer {
|
||||||
private static final byte NULL_TYPE= 0;
|
private static final byte NULL_TYPE= 0;
|
||||||
private static final byte UNSTORABLE_TYPE= (byte) -1;
|
private static final byte UNSTORABLE_TYPE= (byte) -1;
|
||||||
private static final char[] HEX_DIGITS =
|
|
||||||
{ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
|
||||||
|
|
||||||
private final StringBuilder fBuffer;
|
private final StringBuilder fBuffer;
|
||||||
private boolean hexMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for input buffer.
|
* Constructor for input buffer.
|
||||||
|
@ -60,7 +58,13 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
} else {
|
} else {
|
||||||
appendSeparator();
|
appendSeparator();
|
||||||
if (binding instanceof ICPPBinding) {
|
if (binding instanceof ICPPBinding) {
|
||||||
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
|
if (binding instanceof ICPPTemplateParameter) {
|
||||||
|
ICPPTemplateParameter param = (ICPPTemplateParameter) binding;
|
||||||
|
fBuffer.append(param.isParameterPack() ? '*' : '#');
|
||||||
|
fBuffer.append(param.getParameterID());
|
||||||
|
} else {
|
||||||
|
fBuffer.append(ASTTypeUtil.getQualifiedName((ICPPBinding) binding));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fBuffer.append(binding.getNameCharArray());
|
fBuffer.append(binding.getNameCharArray());
|
||||||
}
|
}
|
||||||
|
@ -100,49 +104,27 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putByte(byte b) {
|
public void putByte(byte value) {
|
||||||
appendHexDigit(b >> 4);
|
appendSeparator();
|
||||||
appendHexDigit(b);
|
fBuffer.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putShort(short value) {
|
public void putShort(short value) {
|
||||||
appendHexDigit(value >> 12);
|
appendSeparator();
|
||||||
appendHexDigit(value >> 8);
|
fBuffer.append(value);
|
||||||
appendHexDigit(value >> 4);
|
|
||||||
appendHexDigit(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putInt(int value) {
|
public void putInt(int value) {
|
||||||
appendHexDigit(value >> 28);
|
appendSeparator();
|
||||||
appendHexDigit(value >> 24);
|
fBuffer.append(value);
|
||||||
appendHexDigit(value >> 20);
|
|
||||||
appendHexDigit(value >> 16);
|
|
||||||
appendHexDigit(value >> 12);
|
|
||||||
appendHexDigit(value >> 8);
|
|
||||||
appendHexDigit(value >> 4);
|
|
||||||
appendHexDigit(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putLong(long value) {
|
public void putLong(long value) {
|
||||||
appendHexDigit((int) (value >> 60));
|
appendSeparator();
|
||||||
appendHexDigit((int) (value >> 56));
|
fBuffer.append(value);
|
||||||
appendHexDigit((int) (value >> 52));
|
|
||||||
appendHexDigit((int) (value >> 48));
|
|
||||||
appendHexDigit((int) (value >> 44));
|
|
||||||
appendHexDigit((int) (value >> 40));
|
|
||||||
appendHexDigit((int) (value >> 36));
|
|
||||||
appendHexDigit((int) (value >> 32));
|
|
||||||
appendHexDigit((int) (value >> 28));
|
|
||||||
appendHexDigit((int) (value >> 24));
|
|
||||||
appendHexDigit((int) (value >> 20));
|
|
||||||
appendHexDigit((int) (value >> 16));
|
|
||||||
appendHexDigit((int) (value >> 12));
|
|
||||||
appendHexDigit((int) (value >> 8));
|
|
||||||
appendHexDigit((int) (value >> 4));
|
|
||||||
appendHexDigit((int) value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -153,19 +135,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendHexDigit(int val) {
|
|
||||||
if (hexMode) {
|
|
||||||
appendSeparator();
|
|
||||||
fBuffer.append("0x"); //$NON-NLS-1$
|
|
||||||
hexMode = true;
|
|
||||||
}
|
|
||||||
fBuffer.append(HEX_DIGITS[val & 0xF]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void appendSeparator() {
|
private void appendSeparator() {
|
||||||
if (fBuffer.length() != 0)
|
if (fBuffer.length() != 0)
|
||||||
fBuffer.append(' ');
|
fBuffer.append(' ');
|
||||||
hexMode = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,6 @@ 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.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
@ -37,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
|
@ -127,6 +127,15 @@ public class EvalID extends CPPEvaluation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IValue getValue(IASTNode point) {
|
public IValue getValue(IASTNode point) {
|
||||||
|
IBinding nameOwner = fNameOwner;
|
||||||
|
if (nameOwner == null && fFieldOwner != null)
|
||||||
|
nameOwner = (IBinding) fFieldOwner.getTypeOrFunctionSet(point);
|
||||||
|
|
||||||
|
if (nameOwner instanceof ICPPClassType) {
|
||||||
|
ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, fTemplateArgs, point);
|
||||||
|
if (eval != null)
|
||||||
|
return eval.getValue(point);
|
||||||
|
}
|
||||||
return Value.create(this);
|
return Value.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,31 +303,32 @@ public class EvalID extends CPPEvaluation {
|
||||||
if (Arrays.equals(templateArgs, fTemplateArgs) && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
|
if (Arrays.equals(templateArgs, fTemplateArgs) && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (nameOwner == null && fieldOwner != null)
|
// We don't do name lookup here since it is going to happen anyway when the getValue method
|
||||||
nameOwner = (IBinding) fieldOwner.getTypeOrFunctionSet(point);
|
// is called.
|
||||||
|
|
||||||
if (nameOwner instanceof ICompositeType && point != null) {
|
|
||||||
ICompositeType ownerType = (ICompositeType) nameOwner;
|
|
||||||
LookupData data = new LookupData(fName, templateArgs, point);
|
|
||||||
data.qualified = fQualified;
|
|
||||||
try {
|
|
||||||
CPPSemantics.lookup(data, ownerType.getCompositeScope());
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
IBinding[] bindings = data.getFoundBindings();
|
|
||||||
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
|
||||||
if (binding instanceof IEnumerator) {
|
|
||||||
return new EvalBinding(binding, null);
|
|
||||||
} else if (binding instanceof ICPPMember) {
|
|
||||||
return new EvalMemberAccess(ownerType, ValueCategory.PRVALUE, binding, false);
|
|
||||||
} else if (binding instanceof CPPFunctionSet) {
|
|
||||||
return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs);
|
return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICPPEvaluation resolveName(ICPPClassType nameOwner, ICPPTemplateArgument[] templateArgs,
|
||||||
|
IASTNode point) {
|
||||||
|
LookupData data = new LookupData(fName, templateArgs, point);
|
||||||
|
data.qualified = fQualified;
|
||||||
|
try {
|
||||||
|
CPPSemantics.lookup(data, nameOwner.getCompositeScope());
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
IBinding[] bindings = data.getFoundBindings();
|
||||||
|
IBinding binding = bindings.length == 1 ? bindings[0] : null;
|
||||||
|
if (binding instanceof IEnumerator) {
|
||||||
|
return new EvalBinding(binding, null);
|
||||||
|
} else if (binding instanceof ICPPMember) {
|
||||||
|
return new EvalMemberAccess(nameOwner, ValueCategory.PRVALUE, binding, false);
|
||||||
|
} else if (binding instanceof CPPFunctionSet) {
|
||||||
|
return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||||
int r = fFieldOwner.determinePackSize(tpMap);
|
int r = fFieldOwner.determinePackSize(tpMap);
|
||||||
|
|
Loading…
Add table
Reference in a new issue