1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 11:55:40 +02:00

Bug 485383 - Exclude constructors when expanding using-declarations

during name lookup

This helps us respect the standard's rule that name lookup does not find
constructors, and avoid ambiguities between class and constructor names
that result otherwise.

Change-Id: I17b907bcb35108d7d7e0cc72ca70e07481a5b9ed
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
Nathan Ridge 2016-01-09 01:03:27 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 05daa126a0
commit 8b68a2bb8e
2 changed files with 21 additions and 1 deletions

View file

@ -1477,6 +1477,16 @@ public class AST2CPPTests extends AST2TestBase {
public void _testInheritedTemplateConstructor() throws Exception {
parseAndCheckBindings();
}
// struct base {};
//
// struct derived : public base {
// using base::base;
// base waldo() const;
// };
public void testInheritedConstructorShadowingBaseClassName_485383() throws Exception {
parseAndCheckBindings();
}
// class A { ~A(); };
// class B { ~B(void); };

View file

@ -1360,7 +1360,17 @@ public class CPPSemantics {
if (b instanceof ICPPUsingDeclaration) {
if (data.forDeclaration() == null) {
for (IBinding d : ((ICPPUsingDeclaration) b).getDelegates()) {
if (d != null && !(data.typesOnly && isObject(d))) {
// Note on excluding constructors:
// Constructors are never found during name lookup ([class.ctor] p2).
// Binding resolution sometimes resolves names to constructors, and as
// such, the delegates of a using-declaration can include constructors,
// but when using these delegates in the process of name lookup,
// constructors are ignored. If the binding resolution triggering this
// name lookup wants to ultimately resolve to a constructor, it can do so
// after the name lookup phase, e.g. in the convertClassToConstructor()
// call in postResolution().
if (d != null && !(data.typesOnly && isObject(d)) &&
!(d instanceof ICPPConstructor)) {
result.add(d);
}
}