mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +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();
|
||||
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.ICPPASTNamespaceDefinition;
|
||||
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.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
|
@ -279,10 +280,15 @@ abstract public class CPPScope implements ICPPScope, ICPPASTInternalScope {
|
|||
IBinding binding;
|
||||
if (candidate instanceof IASTName) {
|
||||
final IASTName candName= (IASTName) candidate;
|
||||
if (forceResolve && candName != name && candName != name.getParent()) {
|
||||
binding = candName.resolvePreBinding();
|
||||
IASTName simpleName= candName.getLastName();
|
||||
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 {
|
||||
binding = candName.getLastName().getBinding();
|
||||
binding = simpleName.getPreBinding();
|
||||
}
|
||||
} else {
|
||||
binding= (IBinding) candidate;
|
||||
|
|
Loading…
Add table
Reference in a new issue