mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Correct scope for elaborated type specifiers, bug 270831.
This commit is contained in:
parent
4bef03dc3e
commit
23e918bc08
2 changed files with 14 additions and 6 deletions
|
@ -23,6 +23,7 @@ import java.util.Iterator;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
|
||||
|
@ -7120,4 +7121,13 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
ba.assertNonProblem("A a;", 1, ICPPClassType.class);
|
||||
}
|
||||
|
||||
// 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();
|
||||
assertEquals(EScopeKind.eGlobal, scope.getKind());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -268,10 +266,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();
|
||||
|
|
Loading…
Add table
Reference in a new issue