Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-03-12 15:31:10 +0000
committerMarkus Schorn2008-03-12 15:31:10 +0000
commit96a8f08969a117e5dfca36320391c92e738b0f2e (patch)
tree63458a8389f19d651475f519f89773fd6aa42e17 /core/org.eclipse.cdt.core/parser
parentcdaae2fcba397f88f9369f87d353ec882b89760e (diff)
downloadorg.eclipse.cdt-96a8f08969a117e5dfca36320391c92e738b0f2e.tar.gz
org.eclipse.cdt-96a8f08969a117e5dfca36320391c92e738b0f2e.tar.xz
org.eclipse.cdt-96a8f08969a117e5dfca36320391c92e738b0f2e.zip
Improved fix for: Name resolution for qualified member declarations, bug 222026.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java10
2 files changed, 33 insertions, 9 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java
index 4ca56538139..d29db456ac1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScope.java
@@ -17,6 +17,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -38,6 +39,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectSet;
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.CoreException;
@@ -84,11 +86,11 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
return;
//name belongs to a different scope, don't add it here except it names this scope
- final IASTName[] ns= ((ICPPASTQualifiedName) name).getNames();
- final IASTName ln= ns[ns.length-1];
- if (CPPVisitor.getContainingScope(name) != CPPVisitor.getContainingScope(ln))
+ final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
+ final IASTName[] ns= qname.getNames();
+ if (!canDenoteScopeMember(qname))
return;
- c= ln.toCharArray();
+ c= ns[ns.length-1].toCharArray();
}
else {
c= name.toCharArray();
@@ -108,6 +110,28 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
}
}
+ boolean canDenoteScopeMember(ICPPASTQualifiedName name) {
+ IScope scope= this;
+ IASTName[] na= name.getNames();
+ try {
+ for (int i= na.length-2; i >= 0; i++) {
+ if (scope == null)
+ return false;
+ IASTName n= na[i];
+ final IName scopeName = scope.getScopeName();
+ if (scopeName == null || !CharArrayUtils.equals(scopeName.toCharArray(), n.toCharArray()))
+ return false;
+ scope= scope.getParent();
+ }
+ if (!name.isFullyQualified() || scope == null) {
+ return true;
+ }
+ return ASTInternal.getPhysicalNodeOfScope(scope) instanceof IASTTranslationUnit;
+ } catch (DOMException e) {
+ return false;
+ }
+ }
+
public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException {
IBinding binding= getBindingInAST(name, forceResolve);
if (binding == null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index d0090ecb2fc..168e03fc979 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -1875,12 +1875,12 @@ public class CPPSemantics {
//A qualified name implies the name actually belongs to a different scope, and should
//not be considered here, except the qualifier names the scope itself
- final IASTName[] qn= ((ICPPASTQualifiedName) potential).getNames();
- final IASTName ln= qn[qn.length-1];
- if (CPPVisitor.getContainingScope(ln) != scope)
- return false;
+ final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) potential;
+ if (scope instanceof CPPScope == false || ((CPPScope) scope).canDenoteScopeMember(qname))
+ return false;
- potential= ln;
+ final IASTName[] qn= qname.getNames();
+ potential= qn[qn.length-1];
}
char[] c = potential.toCharArray();
char [] n = data.name();

Back to the top