mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Name resolution problem with friend class template, bug 266992.
This commit is contained in:
parent
8906aaf778
commit
e25410c174
2 changed files with 23 additions and 3 deletions
|
@ -3954,4 +3954,18 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T> class X {};
|
||||||
|
// template <typename T> class X1 {
|
||||||
|
// friend class X<T>;
|
||||||
|
// };
|
||||||
|
// template <typename T> class Y : X1<int> {
|
||||||
|
// void test() {
|
||||||
|
// X<int> x; // problem binding on X<int>
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
public void testFriendClassTemplate_266992() throws Exception {
|
||||||
|
final String code = getAboveComment();
|
||||||
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
@ -279,10 +280,15 @@ abstract public class CPPScope implements ICPPScope, ICPPASTInternalScope {
|
||||||
IBinding binding;
|
IBinding binding;
|
||||||
if (candidate instanceof IASTName) {
|
if (candidate instanceof IASTName) {
|
||||||
final IASTName candName= (IASTName) candidate;
|
final IASTName candName= (IASTName) candidate;
|
||||||
if (forceResolve && candName != name && candName != name.getParent()) {
|
IASTName simpleName= candName.getLastName();
|
||||||
binding = candName.resolvePreBinding();
|
if (simpleName instanceof ICPPASTTemplateId) {
|
||||||
|
simpleName= ((ICPPASTTemplateId) simpleName).getTemplateName();
|
||||||
|
}
|
||||||
|
if (forceResolve && candName != name && simpleName != name) {
|
||||||
|
candName.resolvePreBinding(); // make sure to resolve the template-id
|
||||||
|
binding = simpleName.resolvePreBinding();
|
||||||
} else {
|
} else {
|
||||||
binding = candName.getLastName().getBinding();
|
binding = simpleName.getPreBinding();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding= (IBinding) candidate;
|
binding= (IBinding) candidate;
|
||||||
|
|
Loading…
Add table
Reference in a new issue