mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 317004: Recursive definition of size_t.
This commit is contained in:
parent
2ec6a92a98
commit
bc70607da5
4 changed files with 38 additions and 14 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: org.eclipse.cdt.core.tests
|
Bundle-Name: org.eclipse.cdt.core.tests
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.core.tests; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.core.tests; singleton:=true
|
||||||
Bundle-Version: 5.1.0.qualifier
|
Bundle-Version: 5.3.0.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.core.testplugin.CTestPlugin
|
Bundle-Activator: org.eclipse.cdt.core.testplugin.CTestPlugin
|
||||||
Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
|
Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
|
||||||
org.eclipse.cdt.core.internal.errorparsers.tests;x-internal:=true,
|
org.eclipse.cdt.core.internal.errorparsers.tests;x-internal:=true,
|
||||||
|
|
|
@ -7271,4 +7271,25 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(2, decls.length);
|
assertEquals(2, decls.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// typedef __typeof__((int*)0-(int*)0) ptrdiff_t;
|
||||||
|
// typedef __typeof__(sizeof(int)) size_t;
|
||||||
|
public void testPtrDiffRecursion_317004() throws Exception {
|
||||||
|
final String comment = getAboveComment();
|
||||||
|
String code= comment;
|
||||||
|
parseAndCheckBindings(code, ParserLanguage.C, true);
|
||||||
|
BindingAssertionHelper bh= new BindingAssertionHelper(code, false);
|
||||||
|
ITypedef td= bh.assertNonProblem("ptrdiff_t", 0);
|
||||||
|
assertEquals("int", ASTTypeUtil.getType(td.getType()));
|
||||||
|
td= bh.assertNonProblem("size_t", 0);
|
||||||
|
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
|
||||||
|
|
||||||
|
code= "namespace std {" + comment + "}";
|
||||||
|
parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
||||||
|
bh= new BindingAssertionHelper(code, true);
|
||||||
|
td= bh.assertNonProblem("ptrdiff_t", 0);
|
||||||
|
assertEquals("int", ASTTypeUtil.getType(td.getType()));
|
||||||
|
td= bh.assertNonProblem("size_t", 0);
|
||||||
|
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
|
@ -53,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
@ -67,8 +69,6 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
||||||
|
@ -638,28 +638,31 @@ public class CVisitor extends ASTQueries {
|
||||||
IScope scope = getContainingScope(expr);
|
IScope scope = getContainingScope(expr);
|
||||||
try {
|
try {
|
||||||
IBinding[] bs = scope.find(PTRDIFF_T);
|
IBinding[] bs = scope.find(PTRDIFF_T);
|
||||||
if (bs.length > 0) {
|
for (IBinding b : bs) {
|
||||||
for (IBinding b : bs) {
|
if (b instanceof IType) {
|
||||||
if (b instanceof IType) {
|
if (b instanceof ICInternalBinding == false ||
|
||||||
if (b instanceof ICInternalBinding == false ||
|
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
|
||||||
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
|
return (IType) b;
|
||||||
return (IType) b;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CBasicType(Kind.eInt, IBasicType.IS_UNSIGNED | IBasicType.IS_LONG, expr);
|
return new CBasicType(Kind.eInt, 0, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IType getSize_T(IASTExpression expr) {
|
static IType getSize_T(IASTExpression expr) {
|
||||||
IScope scope = getContainingScope(expr);
|
IScope scope = getContainingScope(expr);
|
||||||
try {
|
try {
|
||||||
IBinding[] bs = scope.find(SIZE_T);
|
IBinding[] bs = scope.find(SIZE_T);
|
||||||
if (bs.length > 0 && bs[0] instanceof IType) {
|
for (IBinding b : bs) {
|
||||||
return (IType) bs[0];
|
if (b instanceof IType) {
|
||||||
|
if (b instanceof ICInternalBinding == false ||
|
||||||
|
CVisitor.declaredBefore(((ICInternalBinding) b).getPhysicalNode(), expr)) {
|
||||||
|
return (IType) b;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -2089,7 +2089,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
basicType= new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
basicType= new CPPBasicType(Kind.eInt, 0);
|
||||||
basicType.setFromExpression(binary);
|
basicType.setFromExpression(binary);
|
||||||
return basicType;
|
return basicType;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue