mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Name lookup in constructor chain initializers, bug 293566.
This commit is contained in:
parent
5e934ed6a5
commit
92305bfbd9
3 changed files with 31 additions and 10 deletions
|
@ -7589,5 +7589,24 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
|
||||
// template <typename T> struct CT {
|
||||
// CT(int) {}
|
||||
// };
|
||||
// namespace ns {
|
||||
// typedef int B;
|
||||
// struct A : CT<B>{
|
||||
// A();
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// ns::A::A() : CT<B>(1) {
|
||||
// }
|
||||
public void testLookupInConstructorChainInitializer_293566() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
bh.assertNonProblem("B>(1)", 1);
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -651,12 +651,6 @@ public class CPPSemantics {
|
|||
n = ((ICPPASTQualifiedName) n).getLastName();
|
||||
}
|
||||
scope = CPPVisitor.getContainingScope(n);
|
||||
} else if (parent instanceof ICPPASTConstructorChainInitializer) {
|
||||
ICPPASTConstructorChainInitializer initializer = (ICPPASTConstructorChainInitializer) parent;
|
||||
IASTFunctionDefinition fdef= (IASTFunctionDefinition) initializer.getParent();
|
||||
IBinding binding = fdef.getDeclarator().getName().resolveBinding();
|
||||
if (!(binding instanceof IProblemBinding))
|
||||
scope = binding.getScope();
|
||||
} else {
|
||||
scope = CPPVisitor.getContainingScope(name, data);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -108,7 +109,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
|
@ -812,6 +812,14 @@ public class CPPVisitor extends ASTQueries {
|
|||
return getContainingScope(ns[ns.length - 1]);
|
||||
}
|
||||
}
|
||||
} else if (node instanceof ICPPASTConstructorChainInitializer) {
|
||||
ICPPASTConstructorChainInitializer initializer = (ICPPASTConstructorChainInitializer) node;
|
||||
IASTFunctionDefinition fdef= (IASTFunctionDefinition) initializer.getParent();
|
||||
IBinding binding = fdef.getDeclarator().getName().resolveBinding();
|
||||
try {
|
||||
return binding.getScope();
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
} else if (node instanceof IASTExpression) {
|
||||
IASTNode parent = node.getParent();
|
||||
if (parent instanceof IASTForStatement) {
|
||||
|
@ -1763,7 +1771,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
basicType= new CPPBasicType(Kind.eInt, ICPPBasicType.IS_LONG | ICPPBasicType.IS_UNSIGNED);
|
||||
basicType= new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
||||
basicType.setFromExpression(binary);
|
||||
return basicType;
|
||||
}
|
||||
|
@ -1795,7 +1803,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
} catch (DOMException e) {
|
||||
}
|
||||
return new CPPBasicType(Kind.eInt, ICPPBasicType.IS_LONG | ICPPBasicType.IS_UNSIGNED);
|
||||
return new CPPBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED);
|
||||
}
|
||||
|
||||
public static IASTProblem[] getProblems(IASTTranslationUnit tu) {
|
||||
|
|
Loading…
Add table
Reference in a new issue