mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 435075 - Avoid an infinite recursion during name resolution
Change-Id: Ie9ac34b184f7b7f6b5196aad716d0fc3696c1e6e Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/32193 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
b18a544841
commit
767ceb4a42
6 changed files with 22 additions and 10 deletions
|
@ -405,4 +405,11 @@ public class IndexCBindingResolutionTest extends IndexBindingResolutionTestBase
|
|||
assertNotNull(numericalValue);
|
||||
assertEquals(i, numericalValue.intValue());
|
||||
}
|
||||
|
||||
// extern char TableValue[10];
|
||||
|
||||
// char TableValue[sizeof TableValue];
|
||||
public void testNameLookupFromArrayModifier_435075() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -829,7 +829,8 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
IType type= fn.getType().getParameterTypes()[0];
|
||||
assertInstance(type, IPointerType.class);
|
||||
type= ((IPointerType) type).getType();
|
||||
assertSame(type, cl);
|
||||
assertInstance(cl, IType.class);
|
||||
assertSameType(type, (IType) cl);
|
||||
}
|
||||
|
||||
// class A {
|
||||
|
|
|
@ -1862,4 +1862,11 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
|
|||
public void testLambdaOwnedByClass() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// extern char TableValue[10];
|
||||
|
||||
// char TableValue[sizeof TableValue];
|
||||
public void testNameLookupFromArrayModifier_435075() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,7 +291,7 @@ public class CScope implements ICScope, IASTInternalScope {
|
|||
}
|
||||
|
||||
private IBinding extractBinding(final IASTName candidate, boolean resolve, IASTName forName) {
|
||||
if (!resolve || acceptDeclaredAfter(forName) || CVisitor.declaredBefore(candidate, forName)) {
|
||||
if (!resolve || acceptDeclaredAfter(forName, candidate) || CVisitor.declaredBefore(candidate, forName)) {
|
||||
if (resolve && candidate != forName) {
|
||||
return candidate.resolveBinding();
|
||||
}
|
||||
|
@ -300,7 +300,10 @@ public class CScope implements ICScope, IASTInternalScope {
|
|||
return null;
|
||||
}
|
||||
|
||||
private boolean acceptDeclaredAfter(IASTName name) {
|
||||
private boolean acceptDeclaredAfter(IASTName name, IASTName candidate) {
|
||||
// Functions may be declared after the point of use.
|
||||
if (!(candidate.getParent() instanceof IASTFunctionDeclarator))
|
||||
return false;
|
||||
if (getKind() != EScopeKind.eGlobal)
|
||||
return false;
|
||||
final ASTNodeProperty propertyInParent = name.getPropertyInParent();
|
||||
|
|
|
@ -1665,6 +1665,7 @@ public class CVisitor extends ASTQueries {
|
|||
static public boolean declaredBefore(IASTNode nodeA, IASTNode nodeB) {
|
||||
if (nodeB == null) return true;
|
||||
if (nodeB.getPropertyInParent() == STRING_LOOKUP_PROPERTY) return true;
|
||||
if (nodeB.getPropertyInParent() == STRING_LOOKUP_TAGS_PROPERTY) return true;
|
||||
|
||||
if (nodeA instanceof ASTNode) {
|
||||
ASTNode nd= (ASTNode) nodeA;
|
||||
|
|
|
@ -1871,13 +1871,6 @@ public class CPPSemantics {
|
|||
int pointOfDecl= -1;
|
||||
if (obj instanceof ICPPInternalBinding) {
|
||||
ICPPInternalBinding cpp = (ICPPInternalBinding) obj;
|
||||
// For bindings in global or namespace scope we don't know whether there is a
|
||||
// previous declaration in one of the skipped header files. For bindings that
|
||||
// are likely to be redeclared we need to assume that there is a declaration
|
||||
// in one of the headers.
|
||||
if (indexBased && acceptDeclaredAfter(cpp)) {
|
||||
return true;
|
||||
}
|
||||
IASTNode[] n = cpp.getDeclarations();
|
||||
if (n != null && n.length > 0) {
|
||||
nd = (ASTNode) n[0];
|
||||
|
|
Loading…
Add table
Reference in a new issue