1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +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 { public void testDependentExpression_395875() throws Exception {
getBindingFromASTName("f(n.foo(0))", 1, ICPPFunction.class); 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,8 +61,6 @@ public interface ITypeMarshalBuffer {
static final short KIND_MASK = 0x001F; static final short KIND_MASK = 0x001F;
final static short FIRST_FLAG = 0x0020;
final static short FLAG1 = 0x0020; final static short FLAG1 = 0x0020;
final static short FLAG2 = 0x0040; final static short FLAG2 = 0x0040;
final static short FLAG3 = 0x0080; final static short FLAG3 = 0x0080;
@ -70,9 +68,12 @@ public interface ITypeMarshalBuffer {
final static short FLAG5 = 0x0200; final static short FLAG5 = 0x0200;
final static short FLAG6 = 0x0400; final static short FLAG6 = 0x0400;
final static short FLAG7 = 0x0800; final static short FLAG7 = 0x0800;
// Can add more flags up to LAST_FLAG. final static short FLAG8 = 0x1000;
final static short FLAG9 = 0x2000;
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(); CoreException unmarshallingError();

View file

@ -227,22 +227,29 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
final int kind= getKind().ordinal(); final int kind= getKind().ordinal();
final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG; final int shiftedKind= kind * ITypeMarshalBuffer.FIRST_FLAG;
final int modifiers= getModifiers(); final int modifiers= getModifiers();
if (modifiers == 0) { short firstBytes = (short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind);
buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind)); if (modifiers != 0)
} else { firstBytes |= ITypeMarshalBuffer.LAST_FLAG;
buffer.putShort((short) (ITypeMarshalBuffer.BASIC_TYPE | shiftedKind | ITypeMarshalBuffer.LAST_FLAG)); if (fAssociatedValue != null)
firstBytes |= ITypeMarshalBuffer.SECOND_LAST_FLAG;
buffer.putShort(firstBytes);
if (modifiers != 0)
buffer.putByte((byte) modifiers); buffer.putByte((byte) modifiers);
} if (fAssociatedValue != null)
buffer.putLong(getAssociatedNumericalValue());
} }
public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException { public static IType unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0; final boolean haveModifiers= (firstBytes & ITypeMarshalBuffer.LAST_FLAG) != 0;
final boolean haveAssociatedNumericalValue= (firstBytes & ITypeMarshalBuffer.SECOND_LAST_FLAG) != 0;
int modifiers= 0; int modifiers= 0;
int kind= (firstBytes & (ITypeMarshalBuffer.LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG; int kind= (firstBytes & (ITypeMarshalBuffer.SECOND_LAST_FLAG - 1)) / ITypeMarshalBuffer.FIRST_FLAG;
if (haveModifiers) { if (haveModifiers)
modifiers= buffer.getByte(); modifiers= buffer.getByte();
} CPPBasicType result = new CPPBasicType(Kind.values()[kind], modifiers);
return new CPPBasicType(Kind.values()[kind], modifiers); if (haveAssociatedNumericalValue)
result.setAssociatedNumericalValue(buffer.getLong());
return result;
} }
@Override @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. * 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. * 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. * 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 MIN_SUPPORTED_VERSION= version(145, 0);
private static final int MAX_SUPPORTED_VERSION= version(144, Short.MAX_VALUE); private static final int MAX_SUPPORTED_VERSION= version(145, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(144, 0); private static final int DEFAULT_VERSION = version(145, 0);
private static int version(int major, int minor) { private static int version(int major, int minor) {
return (major << 16) + minor; return (major << 16) + minor;