1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 407808 - Error involving 0 as null pointer constant in header file

Change-Id: I4b065b932d2ea30b1772c4e0f0b6e2ac8d449e72
Reviewed-on: https://git.eclipse.org/r/12735
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Nathan Ridge 2013-05-12 03:23:05 -04:00 committed by Sergey Prigogin
parent a1f59f3708
commit 1492e28f89
4 changed files with 72 additions and 25 deletions

View file

@ -2227,4 +2227,42 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testDependentExpression_395875() throws Exception {
getBindingFromASTName("f(n.foo(0))", 1, ICPPFunction.class);
}
// struct true_ {
// static const bool value = true;
// };
//
// struct false_ {
// static const bool value = false;
// };
//
// template <typename T>
// struct has_type {
// template <typename U>
// static true_ test(U*);
//
// template <typename U>
// static false_ test(...);
//
// typedef decltype(test<T>(0)) type;
// };
// struct T {
// typedef int type;
// };
//
// template <bool>
// struct A;
//
// template <>
// struct A<true> {
// typedef int type;
// };
//
// int main() {
// A<has_type<T>::type::value>::type a;
// }
public void testIntNullPointerConstant_407808() throws Exception {
checkBindings();
}
}

View file

@ -61,18 +61,19 @@ public interface ITypeMarshalBuffer {
static final short KIND_MASK = 0x001F;
final static short FIRST_FLAG = 0x0020;
final static short FLAG1 = 0x0020;
final static short FLAG2 = 0x0040;
final static short FLAG3 = 0x0080;
final static short FLAG4 = 0x0100;
final static short FLAG5 = 0x0200;
final static short FLAG6 = 0x0400;
final static short FLAG7 = 0x0800;
final static short FLAG8 = 0x1000;
final static short FLAG9 = 0x2000;
final static short FLAG1 = 0x0020;
final static short FLAG2 = 0x0040;
final static short FLAG3 = 0x0080;
final static short FLAG4 = 0x0100;
final static short FLAG5 = 0x0200;
final static short FLAG6 = 0x0400;
final static short FLAG7 = 0x0800;
// Can add more flags up to LAST_FLAG.
final static short LAST_FLAG = 0x2000;
final static short FIRST_FLAG = FLAG1;
final static short SECOND_LAST_FLAG = FLAG8;
final static short LAST_FLAG = FLAG9;
CoreException unmarshallingError();

View file

@ -225,24 +225,31 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
@Override
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int modifiers= getModifiers();
if (modifiers == 0) {
buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind));
} else {
buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind | ITypeMarshalBuffer.LAST_FLAG));
short firstBytes = (short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind);
if (modifiers != 0)
firstBytes |= ITypeMarshalBuffer.LAST_FLAG;
if (fAssociatedValue != null)
firstBytes |= ITypeMarshalBuffer.SECOND_LAST_FLAG;
buffer.putShort(firstBytes);
if (modifiers != 0)
buffer.putByte((byte) modifiers);
}
if (fAssociatedValue != null)
buffer.putLong(getAssociatedNumericalValue());
}
public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0;
int modifiers= 0;
int kind= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG;
if (haveModifiers) {
final boolean haveAssociatedNumericalValue= (firstBytes & ITypeMarshalBuffer.SECOND_LAST_FLAG) != 0;
int modifiers= 0;
int kind= (firstBytes & (ITypeMarshalBuffer.SECOND_LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG;
if (haveModifiers)
modifiers= buffer.getByte();
}
return new CPPBasicType(Kind.values()[kind], modifiers);
CPPBasicType result = new CPPBasicType(Kind.values()[kind], modifiers);
if (haveAssociatedNumericalValue)
result.setAssociatedNumericalValue(buffer.getLong());
return result;
}
@Override

View file

@ -236,10 +236,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 142.0 - Changed marshalling of evaluations to allow more than 15 evaluation kinds, bug 401479.
* 143.0 - Store implied object type in EvalFunctionSet, bug 402409.
* 144.0 - Add support for storing function sets with zero functions in EvalFunctionSet, bug 402498.
* 145.0 - Changed marshalling of CPPBasicType to store the associated numerical value, bug 407808.
*/
private static final int MIN_SUPPORTED_VERSION= version(144, 0);
private static final int MAX_SUPPORTED_VERSION= version(144, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(144, 0);
private static final int MIN_SUPPORTED_VERSION= version(145, 0);
private static final int MAX_SUPPORTED_VERSION= version(145, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(145, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;