1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Declarator ambiguity in function template, bug 265342.

This commit is contained in:
Markus Schorn 2009-02-18 17:47:51 +00:00
parent 9a56d9a65d
commit 586be423c5
5 changed files with 18 additions and 7 deletions

View file

@ -3844,4 +3844,18 @@ public class AST2TemplateTests extends AST2BaseTest {
String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
// template<typename T> class CT {};
// template<class T> CT<T>& getline1(CT<T>& __in);
// template<class T> CT<T>& getline2(CT<T>& __in);
// void test() {
// CT<int> i;
// getline2(i);
// }
public void testAmbiguousDeclaratorInFunctionTemplate_265342() throws Exception {
final String code = getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
bh.assertNonProblem("getline2(i)", 8, ICPPTemplateInstance.class);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
}

View file

@ -166,7 +166,7 @@ final class CPPASTAmbiguityResolver extends ASTVisitor {
}
private void repopulateScope(IASTDeclaration declaration) {
IScope scope= CPPVisitor.getContainingScope(declaration);
IScope scope= CPPVisitor.getContainingNonTemplateScope(declaration);
if (scope instanceof ICPPASTInternalScope) {
CPPSemantics.populateCache((ICPPASTInternalScope) scope, declaration);
}

View file

@ -44,7 +44,7 @@ public class CPPASTAmbiguousCondition extends ASTAmbiguousNode implements IASTAm
@Override
protected void beforeResolution() {
// populate containing scope, so that it will not be affected by the alternative branches.
IScope scope= CPPVisitor.getContainingScope(this);
IScope scope= CPPVisitor.getContainingNonTemplateScope(this);
if (scope instanceof ICPPASTInternalScope) {
((ICPPASTInternalScope) scope).populateCache();
}

View file

@ -44,7 +44,7 @@ public class CPPASTAmbiguousDeclarator extends ASTAmbiguousNode implements IASTA
@Override
protected void beforeResolution() {
// populate containing scope, so that it will not be affected by the alternative branches.
IScope scope= CPPVisitor.getContainingScope(this);
IScope scope= CPPVisitor.getContainingNonTemplateScope(this);
if (scope instanceof ICPPASTInternalScope) {
((ICPPASTInternalScope) scope).populateCache();
}

View file

@ -578,11 +578,8 @@ public class CPPVisitor extends ASTQueries {
IBinding binding= null;
final boolean template= tmplDecl != null;
boolean isFriendDecl= false;
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
ICPPScope scope = (ICPPScope) getContainingNonTemplateScope(name);
try {
while (scope instanceof ICPPTemplateScope) {
scope= (ICPPScope) scope.getParent();
}
if (parent instanceof IASTSimpleDeclaration && scope instanceof ICPPClassScope) {
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier();
if (declSpec.isFriend()) {