Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-05-12 07:23:05 +0000
committerSergey Prigogin2013-05-13 16:02:25 +0000
commit1492e28f8959469b672c3da5439bb238adfb29a5 (patch)
tree6b18737afe2b3643d79683b40dbf2f00f6bffc8a
parenta1f59f37087383e69d0f3c60435f758bc5a30c56 (diff)
downloadorg.eclipse.cdt-1492e28f8959469b672c3da5439bb238adfb29a5.tar.gz
org.eclipse.cdt-1492e28f8959469b672c3da5439bb238adfb29a5.tar.xz
org.eclipse.cdt-1492e28f8959469b672c3da5439bb238adfb29a5.zip
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>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java38
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java7
4 files changed, 72 insertions, 25 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
index dc0ac44e8d3..b4921e3746a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
@@ -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();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
index c163a7d07ba..3394c2ff227 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ITypeMarshalBuffer.java
@@ -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();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
index 625c1bd4b02..d9fc9e1a99a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
@@ -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
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
index d82538ccce7..38ec45e6351 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java
@@ -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;

Back to the top