1
0
Fork 0
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:
Sergey Prigogin 2012-07-26 17:06:30 -07:00
parent e5c9fc3ee6
commit 765363be4a
5 changed files with 52 additions and 70 deletions

View file

@ -5747,7 +5747,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// 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
// }
public void _test14_8_2s8d() throws Exception {
public void test14_8_2s8d() throws Exception {
final String content= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(content, true);
bh.assertProblem("f<A>", 0);

View file

@ -4404,7 +4404,7 @@ public class AST2TemplateTests extends AST2BaseTest {
assertEquals("void (#0 (* ...)())", ASTTypeUtil.getType(f.getType(), true));
assertTrue(f.getParameters()[0].isParameterPack());
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());
f= bh.assertNonProblem("f5", 2);
assertEquals("void (#0 ...)", ASTTypeUtil.getType(f.getType(), true));

View file

@ -184,7 +184,7 @@ abstract public class CPPScope implements ICPPASTInternalScope {
@Override
public IBinding[] getBindings(ScopeLookupData lookup) {
IBinding[] result = getBindingsInAST(lookup);
final IASTTranslationUnit tu = lookup.getLookupPoint().getTranslationUnit();
final IASTTranslationUnit tu = lookup.getTranslationUnit();
if (tu != null) {
IIndex index = tu.getIndex();
if (index != null) {

View file

@ -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.IValue;
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.internal.core.dom.parser.ISerializableEvaluation;
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 final byte NULL_TYPE= 0;
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 boolean hexMode;
/**
* Constructor for input buffer.
@ -60,7 +58,13 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
} else {
appendSeparator();
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 {
fBuffer.append(binding.getNameCharArray());
}
@ -100,49 +104,27 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
}
@Override
public void putByte(byte b) {
appendHexDigit(b >> 4);
appendHexDigit(b);
public void putByte(byte value) {
appendSeparator();
fBuffer.append(value);
}
@Override
public void putShort(short value) {
appendHexDigit(value >> 12);
appendHexDigit(value >> 8);
appendHexDigit(value >> 4);
appendHexDigit(value);
appendSeparator();
fBuffer.append(value);
}
@Override
public void putInt(int value) {
appendHexDigit(value >> 28);
appendHexDigit(value >> 24);
appendHexDigit(value >> 20);
appendHexDigit(value >> 16);
appendHexDigit(value >> 12);
appendHexDigit(value >> 8);
appendHexDigit(value >> 4);
appendHexDigit(value);
appendSeparator();
fBuffer.append(value);
}
@Override
public void putLong(long value) {
appendHexDigit((int) (value >> 60));
appendHexDigit((int) (value >> 56));
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);
appendSeparator();
fBuffer.append(value);
}
@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() {
if (fBuffer.length() != 0)
fBuffer.append(' ');
hexMode = false;
}
@Override

View file

@ -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.IASTUnaryExpression;
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.IFunction;
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.ICPPASTTemplateId;
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.ICPPEnumeration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
@ -127,6 +127,15 @@ public class EvalID extends CPPEvaluation {
@Override
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);
}
@ -294,31 +303,32 @@ public class EvalID extends CPPEvaluation {
if (Arrays.equals(templateArgs, fTemplateArgs) && fieldOwner == fFieldOwner && nameOwner == fNameOwner)
return this;
if (nameOwner == null && fieldOwner != null)
nameOwner = (IBinding) fieldOwner.getTypeOrFunctionSet(point);
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);
}
}
// We don't do name lookup here since it is going to happen anyway when the getValue method
// is called.
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
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
int r = fFieldOwner.determinePackSize(tpMap);