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:
parent
e2cbee5c2b
commit
0ae8bcc48c
3 changed files with 7 additions and 6 deletions
|
@ -7314,7 +7314,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
parseAndCheckBindings(code, C, true);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, false);
|
||||
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);
|
||||
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
|
||||
|
||||
|
@ -7322,7 +7322,7 @@ public class AST2Tests extends AST2TestBase {
|
|||
parseAndCheckBindings(code, CPP, true);
|
||||
bh= new BindingAssertionHelper(code, true);
|
||||
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);
|
||||
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -216,8 +216,9 @@ import org.eclipse.cdt.internal.core.index.IIndexScope;
|
|||
* Collection of methods to extract information from a C++ translation unit.
|
||||
*/
|
||||
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 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 char[] BEGIN = BEGIN_STR.toCharArray();
|
||||
|
@ -225,7 +226,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
static final String STD = "std"; //$NON-NLS-1$
|
||||
private static final char[] SIZE_T = "size_t".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] PTRDIFF_T = "ptrdiff_t".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] TYPE_INFO= "type_info".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] TYPE_INFO = "type_info".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] INITIALIZER_LIST = "initializer_list".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[][] EMPTY_CHAR_ARRAY_ARRAY = {};
|
||||
public static final IASTInitializerClause[] NO_ARGS = {};
|
||||
|
@ -2276,7 +2277,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
|
||||
public static IType getPointerDiffType(final IASTNode point) {
|
||||
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue