mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Bug 286741.
This commit is contained in:
parent
44d46d0b79
commit
7bbba2e9ec
2 changed files with 26 additions and 3 deletions
|
@ -4114,4 +4114,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>
|
||||||
|
// struct A {
|
||||||
|
// typedef A<T> Self;
|
||||||
|
// friend Self f(Self p) { return Self(); }
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void test(A<int> x) {
|
||||||
|
// f(x);
|
||||||
|
// }
|
||||||
|
public void testInlineFriendFunction_286741() throws Exception {
|
||||||
|
final String code = getAboveComment();
|
||||||
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -806,10 +806,19 @@ public class CPPVisitor extends ASTQueries {
|
||||||
while (parent.getParent() instanceof IASTDeclarator)
|
while (parent.getParent() instanceof IASTDeclarator)
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
ASTNodeProperty prop = parent.getPropertyInParent();
|
||||||
if (prop == IASTSimpleDeclaration.DECLARATOR)
|
if (prop == IASTSimpleDeclaration.DECLARATOR) {
|
||||||
return dtor.getFunctionScope();
|
return dtor.getFunctionScope();
|
||||||
else if (prop == IASTFunctionDefinition.DECLARATOR)
|
} else if (prop == IASTFunctionDefinition.DECLARATOR) {
|
||||||
return ((IASTCompoundStatement) ((IASTFunctionDefinition) parent.getParent()).getBody()).getScope();
|
IASTFunctionDefinition funcDef = (IASTFunctionDefinition) parent.getParent();
|
||||||
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) funcDef.getDeclSpecifier();
|
||||||
|
if (declSpec.isFriend()) {
|
||||||
|
parent = funcDef.getParent();
|
||||||
|
if (parent instanceof IASTCompositeTypeSpecifier) {
|
||||||
|
return ((IASTCompositeTypeSpecifier) parent).getScope();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ((IASTCompoundStatement) funcDef.getBody()).getScope();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (parent instanceof ICPPASTTemplateDeclaration) {
|
} else if (parent instanceof ICPPASTTemplateDeclaration) {
|
||||||
return CPPTemplates.getContainingScope(node);
|
return CPPTemplates.getContainingScope(node);
|
||||||
|
|
Loading…
Add table
Reference in a new issue