1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 401093 - Expression type for pointer difference does not fit on

64bit machines
This commit is contained in:
Sergey Prigogin 2013-02-18 17:49:55 -08:00
parent e2cbee5c2b
commit 0ae8bcc48c
3 changed files with 7 additions and 6 deletions

View file

@ -7314,7 +7314,7 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, C, true); parseAndCheckBindings(code, C, true);
BindingAssertionHelper bh= new BindingAssertionHelper(code, false); BindingAssertionHelper bh= new BindingAssertionHelper(code, false);
ITypedef td= bh.assertNonProblem("ptrdiff_t", 0); ITypedef td= bh.assertNonProblem("ptrdiff_t", 0);
assertEquals("int", ASTTypeUtil.getType(td.getType())); assertEquals("long int", ASTTypeUtil.getType(td.getType()));
td= bh.assertNonProblem("size_t", 0); td= bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType())); assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
@ -7322,7 +7322,7 @@ public class AST2Tests extends AST2TestBase {
parseAndCheckBindings(code, CPP, true); parseAndCheckBindings(code, CPP, true);
bh= new BindingAssertionHelper(code, true); bh= new BindingAssertionHelper(code, true);
td= bh.assertNonProblem("ptrdiff_t", 0); td= bh.assertNonProblem("ptrdiff_t", 0);
assertEquals("int", ASTTypeUtil.getType(td.getType())); assertEquals("long int", ASTTypeUtil.getType(td.getType()));
td= bh.assertNonProblem("size_t", 0); td= bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType())); assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
} }

View file

@ -649,7 +649,7 @@ public class CVisitor extends ASTQueries {
} }
} }
return new CBasicType(Kind.eInt, 0, expr); return new CBasicType(Kind.eInt, IBasicType.IS_LONG, expr);
} }
static IType get_SIZE_T(IASTExpression expr) { static IType get_SIZE_T(IASTExpression expr) {

View file

@ -216,8 +216,9 @@ import org.eclipse.cdt.internal.core.index.IIndexScope;
* Collection of methods to extract information from a C++ translation unit. * Collection of methods to extract information from a C++ translation unit.
*/ */
public class CPPVisitor extends ASTQueries { public class CPPVisitor extends ASTQueries {
private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0); private static final CPPBasicType INT_TYPE = new CPPBasicType(Kind.eInt, 0);
private static final CPPBasicType LONG_TYPE = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG);
private static final CPPBasicType UNSIGNED_LONG = new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
public static final String BEGIN_STR = "begin"; //$NON-NLS-1$ public static final String BEGIN_STR = "begin"; //$NON-NLS-1$
public static final char[] BEGIN = BEGIN_STR.toCharArray(); public static final char[] BEGIN = BEGIN_STR.toCharArray();
@ -2276,7 +2277,7 @@ public class CPPVisitor extends ASTQueries {
public static IType getPointerDiffType(final IASTNode point) { public static IType getPointerDiffType(final IASTNode point) {
IType t= getStdType(point, PTRDIFF_T); IType t= getStdType(point, PTRDIFF_T);
return t != null ? t : INT_TYPE; return t != null ? t : LONG_TYPE;
} }
private static IType getStdType(final IASTNode node, char[] name) { private static IType getStdType(final IASTNode node, char[] name) {