Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2009-04-15 08:01:08 +0000
committerMarkus Schorn2009-04-15 08:01:08 +0000
commit96a447d7d60bc0eb60bf062ec7619dd948a11d78 (patch)
treeb9c8c2a4c29e2aa41df589a5fb6b3d0204667da0
parentee63904aa294e55afcfe598843b92ab3c4c8e7df (diff)
downloadorg.eclipse.cdt-96a447d7d60bc0eb60bf062ec7619dd948a11d78.tar.gz
org.eclipse.cdt-96a447d7d60bc0eb60bf062ec7619dd948a11d78.tar.xz
org.eclipse.cdt-96a447d7d60bc0eb60bf062ec7619dd948a11d78.zip
Correct scope for elaborated type specifiers, bug 270831.v200904221244
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java10
2 files changed, 14 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index d95b125a8a9..3657df3b58a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -101,6 +101,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
@@ -6251,4 +6252,13 @@ public class AST2CPPTests extends AST2BaseTest {
ba.assertNonProblem("a; //5", 1, ICPPField.class);
ba.assertProblem("a; //6", 1);
}
+
+ // template <class T> class Moo;
+ // bool getFile(Moo <class Foo> & res);
+ public void testScopeOfClassFwdDecl_270831() throws Exception {
+ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
+ ICPPClassType t= ba.assertNonProblem("Foo", 3, ICPPClassType.class);
+ IScope scope= t.getScope();
+ assertInstance(scope, ICPPNamespaceScope.class);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
index 80c40b50f6c..de16b42f034 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
@@ -20,10 +20,8 @@ import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
@@ -294,10 +292,10 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
IScope scope = CPPVisitor.getContainingScope( name );
if( definition == null && name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME ){
IASTNode node = declarations[0].getParent().getParent();
- if( node instanceof IASTFunctionDefinition || node instanceof IASTParameterDeclaration ||
- ( node instanceof IASTSimpleDeclaration &&
- ( ((IASTSimpleDeclaration) node).getDeclarators().length > 0 || getElaboratedTypeSpecifier().isFriend() ) ) )
- {
+ if (node instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration) node).getDeclarators().length == 0
+ && !getElaboratedTypeSpecifier().isFriend()) {
+ // 3.3.1.5 class-key identifier ;
+ } else {
while( scope instanceof ICPPClassScope || scope instanceof ICPPFunctionScope ){
try {
scope = scope.getParent();

Back to the top