mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42: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:
parent
dddc340130
commit
01a45c3d00
3 changed files with 49 additions and 0 deletions
|
@ -12323,4 +12323,42 @@ public class AST2CPPTests extends AST2CPPTestBase {
|
|||
public void testSizeofArrayField_512932() throws Exception {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1365,6 +1365,12 @@ public class CPPSemantics {
|
|||
bindings = ArrayUtil.filter(bindings, new RecursionResolvingBindingFilter());
|
||||
}
|
||||
|
||||
if (data.namespacesOnly) {
|
||||
bindings = ArrayUtil.filter(bindings, (argument) -> {
|
||||
return argument instanceof ICPPNamespace;
|
||||
});
|
||||
}
|
||||
|
||||
return expandUsingDeclarationsAndRemoveObjects(bindings, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.ICPPASTInitializerClause;
|
||||
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.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
|
@ -97,6 +98,7 @@ public class LookupData extends ScopeLookupData {
|
|||
public boolean qualified;
|
||||
|
||||
public boolean forUsingDeclaration;
|
||||
public boolean namespacesOnly;
|
||||
|
||||
/** When computing the cost of a method call, treat the first argument as the implied object. */
|
||||
public boolean argsContainImpliedObject;
|
||||
|
@ -174,6 +176,9 @@ public class LookupData extends ScopeLookupData {
|
|||
typesOnly= true;
|
||||
} else if (nameParent instanceof ICPPASTUsingDeclaration) {
|
||||
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) {
|
||||
fDeclarator= (IASTDeclarator) nameParent;
|
||||
} else if (nameParent instanceof IASTFieldReference) {
|
||||
|
|
Loading…
Add table
Reference in a new issue