1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Treat __attribute__ ((__mode__ (__DI__))) as long instead of long long

in 64-bit mode.
This commit is contained in:
Sergey Prigogin 2012-04-13 18:20:37 -07:00
parent 89e9f5d607
commit 2b8e34b777
5 changed files with 43 additions and 24 deletions

View file

@ -107,12 +107,14 @@ public class AST2BaseTest extends BaseTestCase {
map.put("__GNUC__", "4");
map.put("__GNUC_MINOR__", "5");
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
return map;
}
private static Map<String, String> getStdMap() {
Map<String, String> map= new HashMap<String, String>();
map.put("__SIZEOF_INT__", "4");
map.put("__SIZEOF_LONG__", "8");
return map;
}

View file

@ -9569,8 +9569,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void f(int16_t*) {}
// void f(int32_t*) {}
// void f(int64_t*) {}
// void f(word_t*) {}
// void test(signed char* i8, short* i16, int* i32, long long* i64, word_t* word) {
// void test(signed char* i8, short* i16, int* i32, long* i64, word_t* word) {
// f(i8);
// f(i16);
// f(i32);
@ -9584,11 +9583,13 @@ public class AST2CPPTests extends AST2BaseTest {
for (int i = 0; i < calls.length; i++) {
functions[i] = bh.assertNonProblem(calls[i], 1, ICPPFunction.class);
}
for (int i = 0; i < functions.length; i++) {
for (int j = i + 1; j < functions.length; j++) {
for (int i = 0; i < functions.length - 1; i++) {
for (int j = 0; j < i ; j++) {
assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function",
functions[i], functions[j]);
}
}
assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions",
functions[calls.length - 1], functions[calls.length - 2]);
}
}

View file

@ -50,22 +50,22 @@ public class SizeofCalculator {
private static final SizeAndAlignment SIZE_1 = new SizeAndAlignment(1, 1);
private final SizeAndAlignment size_2;
private final SizeAndAlignment size_4;
private final SizeAndAlignment size_8;
private final SizeAndAlignment sizeof_pointer;
private final SizeAndAlignment sizeof_int;
private final SizeAndAlignment sizeof_long;
private final SizeAndAlignment sizeof_long_long;
private final SizeAndAlignment sizeof_short;
private final SizeAndAlignment sizeof_bool;
private final SizeAndAlignment sizeof_wchar_t;
private final SizeAndAlignment sizeof_float;
private final SizeAndAlignment sizeof_complex_float;
private final SizeAndAlignment sizeof_double;
private final SizeAndAlignment sizeof_complex_double;
private final SizeAndAlignment sizeof_long_double;
private final SizeAndAlignment sizeof_complex_long_double;
public final SizeAndAlignment size_2;
public final SizeAndAlignment size_4;
public final SizeAndAlignment size_8;
public final SizeAndAlignment sizeof_pointer;
public final SizeAndAlignment sizeof_int;
public final SizeAndAlignment sizeof_long;
public final SizeAndAlignment sizeof_long_long;
public final SizeAndAlignment sizeof_short;
public final SizeAndAlignment sizeof_bool;
public final SizeAndAlignment sizeof_wchar_t;
public final SizeAndAlignment sizeof_float;
public final SizeAndAlignment sizeof_complex_float;
public final SizeAndAlignment sizeof_double;
public final SizeAndAlignment sizeof_complex_double;
public final SizeAndAlignment sizeof_long_double;
public final SizeAndAlignment sizeof_complex_long_double;
public SizeofCalculator(IASTTranslationUnit ast) {
int maxAlignment = 32;

View file

@ -94,7 +94,6 @@ import org.eclipse.cdt.core.parser.util.AttributeUtil;
import org.eclipse.cdt.core.parser.util.CharArraySet;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.IContentAssistMatcher;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
@ -102,6 +101,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
/**
@ -1283,8 +1283,16 @@ public class CVisitor extends ASTQueries {
} else if (CharArrayUtils.equals(mode, "__SI__") || CharArrayUtils.equals(mode, "SI")) { //$NON-NLS-1$ //$NON-NLS-2$
type = new CBasicType(IBasicType.Kind.eInt, getSignModifiers(basicType));
} else if (CharArrayUtils.equals(mode, "__DI__") || CharArrayUtils.equals(mode, "DI")) { //$NON-NLS-1$ //$NON-NLS-2$
SizeofCalculator sizeofs = new SizeofCalculator(declarator.getTranslationUnit());
int modifier;
if (sizeofs.sizeof_long != null && sizeofs.sizeof_int != null &&
sizeofs.sizeof_long.size == 2 * sizeofs.sizeof_int.size) {
modifier = IBasicType.IS_LONG;
} else {
modifier = IBasicType.IS_LONG_LONG;
}
type = new CBasicType(IBasicType.Kind.eInt,
IBasicType.IS_LONG_LONG | getSignModifiers(basicType));
modifier | getSignModifiers(basicType));
} else if (CharArrayUtils.equals(mode, "__word__") || CharArrayUtils.equals(mode, "word")) { //$NON-NLS-1$ //$NON-NLS-2$
type = new CBasicType(IBasicType.Kind.eInt,
IBasicType.IS_LONG | getSignModifiers(basicType));

View file

@ -158,11 +158,11 @@ import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.AttributeUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression;
@ -1865,8 +1865,16 @@ public class CPPVisitor extends ASTQueries {
} else if (CharArrayUtils.equals(mode, "__SI__") || CharArrayUtils.equals(mode, "SI")) { //$NON-NLS-1$ //$NON-NLS-2$
type = new CPPBasicType(IBasicType.Kind.eInt, getSignModifiers(basicType));
} else if (CharArrayUtils.equals(mode, "__DI__") || CharArrayUtils.equals(mode, "DI")) { //$NON-NLS-1$ //$NON-NLS-2$
SizeofCalculator sizeofs = new SizeofCalculator(declarator.getTranslationUnit());
int modifier;
if (sizeofs.sizeof_long != null && sizeofs.sizeof_int != null &&
sizeofs.sizeof_long.size == 2 * sizeofs.sizeof_int.size) {
modifier = IBasicType.IS_LONG;
} else {
modifier = IBasicType.IS_LONG_LONG;
}
type = new CPPBasicType(IBasicType.Kind.eInt,
IBasicType.IS_LONG_LONG | getSignModifiers(basicType));
modifier | getSignModifiers(basicType));
} else if (CharArrayUtils.equals(mode, "__word__") || CharArrayUtils.equals(mode, "word")) { //$NON-NLS-1$ //$NON-NLS-2$
type = new CPPBasicType(IBasicType.Kind.eInt,
IBasicType.IS_LONG | getSignModifiers(basicType));