mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +02:00
Resolution of inline friend functions. Bug 284690.
This commit is contained in:
parent
d9f76e60dc
commit
936d9e6b75
3 changed files with 17 additions and 3 deletions
|
@ -7294,7 +7294,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
// void test(A a) {
|
// void test(A a) {
|
||||||
// m(a);
|
// m(a);
|
||||||
// }
|
// }
|
||||||
public void _testInlineFriendFunction_284690() throws Exception {
|
public void testInlineFriendFunction_284690() throws Exception {
|
||||||
final String code = getAboveComment();
|
final String code = getAboveComment();
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -769,6 +769,10 @@ public class CPPVisitor extends ASTQueries {
|
||||||
} else if (parent instanceof IASTForStatement) {
|
} else if (parent instanceof IASTForStatement) {
|
||||||
return ((IASTForStatement) parent).getScope();
|
return ((IASTForStatement) parent).getScope();
|
||||||
} else if (parent instanceof IASTCompositeTypeSpecifier) {
|
} else if (parent instanceof IASTCompositeTypeSpecifier) {
|
||||||
|
if (node instanceof IASTFunctionDefinition &&
|
||||||
|
((ICPPASTDeclSpecifier) ((IASTFunctionDefinition) node).getDeclSpecifier()).isFriend()) {
|
||||||
|
return getContainingScope(parent);
|
||||||
|
}
|
||||||
return ((IASTCompositeTypeSpecifier) parent).getScope();
|
return ((IASTCompositeTypeSpecifier) parent).getScope();
|
||||||
} else if (parent instanceof ICPPASTNamespaceDefinition) {
|
} else if (parent instanceof ICPPASTNamespaceDefinition) {
|
||||||
return ((ICPPASTNamespaceDefinition) parent).getScope();
|
return ((ICPPASTNamespaceDefinition) parent).getScope();
|
||||||
|
|
|
@ -7,12 +7,15 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
|
@ -61,6 +64,13 @@ class FriendCollector extends ASTVisitor {
|
||||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
} else if (declaration instanceof IASTFunctionDefinition) {
|
||||||
|
IASTFunctionDefinition funcDefinition = (IASTFunctionDefinition) declaration;
|
||||||
|
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) funcDefinition.getDeclSpecifier();
|
||||||
|
if (declSpec.isFriend()) {
|
||||||
|
IASTFunctionDeclarator declarator = funcDefinition.getDeclarator();
|
||||||
|
ASTInternal.addName(fScope, declarator.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue