1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 517402 - Ambiguous namespace, conflicting with a different kind of symbol

Change-Id: I5a648e23f1222c1bbf75a13b367dd51dd6231f61
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
This commit is contained in:
Marc-Andre Laperle 2017-07-20 17:15:57 -04:00 committed by Marc-André Laperle
parent dddc340130
commit 01a45c3d00
3 changed files with 49 additions and 0 deletions

View file

@ -12323,4 +12323,42 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testSizeofArrayField_512932() throws Exception { public void testSizeofArrayField_512932() throws Exception {
parseAndCheckBindings(); parseAndCheckBindings();
} }
//void ns2 ();
//
//namespace ns1 {
//namespace ns2 {
//class TestNameSpace {
//public:
// TestNameSpace();
//};
//}
//}
//
//using namespace ns1;
//using namespace ns2; //ns2 shouldn't be ambiguous because only namespace names should be considered.
//
//TestNameSpace::TestNameSpace() {
//}
public void testUsingDirectiveNamespaceWithPreviousFunctionName_517402() throws Exception {
parseAndCheckBindings();
}
//void ns2 ();
//namespace ns1 {
//namespace ns2 {
//class TestNameSpace {
//public:
// TestNameSpace();
//};
//}
//}
//
//using namespace ns1;
//namespace ns12 = ns2;
//ns12::TestNameSpace::TestNameSpace() {
//}
public void testNamespaceAliasNamespaceWithPreviousFunctionName_517402() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -1365,6 +1365,12 @@ public class CPPSemantics {
bindings = ArrayUtil.filter(bindings, new RecursionResolvingBindingFilter()); bindings = ArrayUtil.filter(bindings, new RecursionResolvingBindingFilter());
} }
if (data.namespacesOnly) {
bindings = ArrayUtil.filter(bindings, (argument) -> {
return argument instanceof ICPPNamespace;
});
}
return expandUsingDeclarationsAndRemoveObjects(bindings, data); return expandUsingDeclarationsAndRemoveObjects(bindings, data);
} }

View file

@ -57,6 +57,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDesignator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@ -97,6 +98,7 @@ public class LookupData extends ScopeLookupData {
public boolean qualified; public boolean qualified;
public boolean forUsingDeclaration; public boolean forUsingDeclaration;
public boolean namespacesOnly;
/** When computing the cost of a method call, treat the first argument as the implied object. */ /** When computing the cost of a method call, treat the first argument as the implied object. */
public boolean argsContainImpliedObject; public boolean argsContainImpliedObject;
@ -174,6 +176,9 @@ public class LookupData extends ScopeLookupData {
typesOnly= true; typesOnly= true;
} else if (nameParent instanceof ICPPASTUsingDeclaration) { } else if (nameParent instanceof ICPPASTUsingDeclaration) {
forUsingDeclaration= true; forUsingDeclaration= true;
} else if (nameParent instanceof ICPPASTUsingDirective || nameParent instanceof ICPPASTNamespaceAlias) {
// [basic.lookup.udir]: Only namespace names are considered
namespacesOnly= true;
} else if (nameParent instanceof IASTDeclarator) { } else if (nameParent instanceof IASTDeclarator) {
fDeclarator= (IASTDeclarator) nameParent; fDeclarator= (IASTDeclarator) nameParent;
} else if (nameParent instanceof IASTFieldReference) { } else if (nameParent instanceof IASTFieldReference) {