Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java32
1 files changed, 12 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index e65ac2a2501..b1729a40d35 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -580,10 +580,15 @@ public class CPPVisitor extends ASTQueries {
boolean isFriendDecl= false;
ICPPScope scope = (ICPPScope) getContainingNonTemplateScope(name);
try {
- if (parent instanceof IASTSimpleDeclaration && scope instanceof ICPPClassScope) {
- ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier();
- if (declSpec.isFriend()) {
- isFriendDecl= true;
+ if (scope instanceof ICPPClassScope) {
+ if (parent instanceof IASTSimpleDeclaration) {
+ ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) parent).getDeclSpecifier();
+ isFriendDecl= declSpec.isFriend();
+ } else if (parent instanceof IASTFunctionDefinition) {
+ ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) parent).getDeclSpecifier();
+ isFriendDecl= declSpec.isFriend();
+ }
+ if (isFriendDecl) {
try {
while (scope.getKind() == EScopeKind.eClassType) {
scope = (ICPPScope) getParentScope(scope, name.getTranslationUnit());
@@ -773,10 +778,6 @@ public class CPPVisitor extends ASTQueries {
} else if (parent instanceof IASTForStatement) {
return ((IASTForStatement) parent).getScope();
} else if (parent instanceof IASTCompositeTypeSpecifier) {
- if (node instanceof IASTFunctionDefinition &&
- ((ICPPASTDeclSpecifier) ((IASTFunctionDefinition) node).getDeclSpecifier()).isFriend()) {
- return getContainingScope(parent);
- }
return ((IASTCompositeTypeSpecifier) parent).getScope();
} else if (parent instanceof ICPPASTNamespaceDefinition) {
return ((ICPPASTNamespaceDefinition) parent).getScope();
@@ -810,19 +811,10 @@ public class CPPVisitor extends ASTQueries {
while (parent.getParent() instanceof IASTDeclarator)
parent = parent.getParent();
ASTNodeProperty prop = parent.getPropertyInParent();
- if (prop == IASTSimpleDeclaration.DECLARATOR) {
+ if (prop == IASTSimpleDeclaration.DECLARATOR)
return dtor.getFunctionScope();
- } else if (prop == IASTFunctionDefinition.DECLARATOR) {
- 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 (prop == IASTFunctionDefinition.DECLARATOR)
+ return ((IASTCompoundStatement) ((IASTFunctionDefinition) parent.getParent()).getBody()).getScope();
}
} else if (parent instanceof ICPPASTTemplateDeclaration) {
return CPPTemplates.getContainingScope(node);

Back to the top