mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 19:25:38 +02:00
Fix redefinition of t_ptrdiff, bug 230895.
This commit is contained in:
parent
a9dcca01fd
commit
3817999a3f
3 changed files with 30 additions and 4 deletions
|
@ -4721,4 +4721,19 @@ public class AST2Tests extends AST2BaseTest {
|
|||
assertSame(b2, b3);
|
||||
}
|
||||
}
|
||||
|
||||
// #define foo __typeof__((int*)0 - (int*)0)
|
||||
// typedef foo ptrdiff_t;
|
||||
public void testRedefinePtrdiff_Bug230895() throws Exception {
|
||||
final boolean[] isCpps= {false, true};
|
||||
String code= getAboveComment();
|
||||
for (boolean isCpp : isCpps) {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp);
|
||||
IBinding b1= ba.assertNonProblem("ptrdiff_t", 9);
|
||||
assertInstance(b1, ITypedef.class);
|
||||
ITypedef td= (ITypedef) b1;
|
||||
IType t= td.getType();
|
||||
assertFalse(t instanceof ITypedef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -736,8 +736,15 @@ public class CVisitor {
|
|||
IScope scope = getContainingScope(expression);
|
||||
try {
|
||||
IBinding[] bs = scope.find(PTRDIFF_T);
|
||||
if (bs.length > 0 && bs[0] instanceof IType) {
|
||||
return (IType) bs[0];
|
||||
if (bs.length > 0) {
|
||||
for (IBinding b : bs) {
|
||||
if (b instanceof IType) {
|
||||
if (b instanceof ICInternalBinding == false ||
|
||||
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), binary)) {
|
||||
return (IType) b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
|
|
|
@ -1918,8 +1918,12 @@ public class CPPVisitor {
|
|||
IScope scope = getContainingScope(expression);
|
||||
try {
|
||||
IBinding[] bs = scope.find(PTRDIFF_T);
|
||||
if (bs.length > 0 && bs[0] instanceof IType) {
|
||||
return (IType) bs[0];
|
||||
if (bs.length > 0) {
|
||||
for (IBinding b : bs) {
|
||||
if (b instanceof IType && CPPSemantics.declaredBefore(b, binary, false)) {
|
||||
return (IType) b;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue