mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-06 00:25:25 +02:00
Bug 356955: Lookup for overloaded operator.
This commit is contained in:
parent
e75a7388a0
commit
7902fd1c77
3 changed files with 50 additions and 25 deletions
|
@ -18,6 +18,7 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
@ -1308,4 +1309,31 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
||||||
IFunction f= getBindingFromASTName("fun", 0);
|
IFunction f= getBindingFromASTName("fun", 0);
|
||||||
ITypedef t= getBindingFromASTName("Type", 0);
|
ITypedef t= getBindingFromASTName("Type", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct base {
|
||||||
|
// virtual void operator+(base const &) { }
|
||||||
|
// virtual void operator-(base const &) { }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// #include "header.h"
|
||||||
|
// struct inter : public base {
|
||||||
|
// virtual void operator+(base const &){}
|
||||||
|
// };
|
||||||
|
// struct sub : public inter {
|
||||||
|
// void doSomething() {
|
||||||
|
// base *left, *right;
|
||||||
|
//
|
||||||
|
// *left + *right;
|
||||||
|
// *left - *right;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
public void test_Bug356982() throws Exception {
|
||||||
|
IASTName name= findName("+ ", 1);
|
||||||
|
assertTrue(name instanceof IASTImplicitName);
|
||||||
|
assertEquals("base", name.resolveBinding().getOwner().getName());
|
||||||
|
|
||||||
|
name= findName("- ", 1);
|
||||||
|
assertTrue(name instanceof IASTImplicitName);
|
||||||
|
assertEquals("base", name.resolveBinding().getOwner().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
|
|
||||||
IIndex index;
|
IIndex index;
|
||||||
|
|
||||||
protected StringBuffer[] getContentsForTest(int blocks) throws IOException {
|
protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
|
||||||
return TestSourceReader.getContentsForTest(
|
return TestSourceReader.getContentsForTest(
|
||||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
|
|
||||||
// class B {};
|
// class B {};
|
||||||
public void testPairDisjointContent() throws Exception {
|
public void testPairDisjointContent() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(2);
|
CharSequence[] contents = getContentsForTest(2);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -117,7 +117,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// void foo(X::B2 c) {}
|
// void foo(X::B2 c) {}
|
||||||
// namespace X { class A2 {}; B2 b; C2 c; }
|
// namespace X { class A2 {}; B2 b; C2 c; }
|
||||||
public void testTripleLinear() throws Exception {
|
public void testTripleLinear() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(3);
|
CharSequence[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -224,11 +224,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// namespace X { class A2 {}; }
|
// namespace X { class A2 {}; }
|
||||||
// B1 ab;
|
// B1 ab;
|
||||||
public void testTripleUpwardV() throws Exception {
|
public void testTripleUpwardV() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(3);
|
CharSequence[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
|
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
|
||||||
pb.addFile("h2.h", contents[1]);
|
pb.addFile("h2.h", contents[1]);
|
||||||
|
@ -313,7 +311,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
// void foo(A1 a, A1 b) {}
|
// void foo(A1 a, A1 b) {}
|
||||||
// namespace X { class A2 {}; }
|
// namespace X { class A2 {}; }
|
||||||
public void testTripleDownwardV() throws Exception {
|
public void testTripleDownwardV() throws Exception {
|
||||||
StringBuffer[] contents = getContentsForTest(3);
|
CharSequence[] contents = getContentsForTest(3);
|
||||||
List projects = new ArrayList();
|
List projects = new ArrayList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -388,11 +386,9 @@ public class IndexCompositeTests extends BaseTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts binding counts, and returns the index tested against
|
* Asserts binding counts, and returns the index tested against
|
||||||
* @param cprojA the project to obtain the index for
|
|
||||||
* @param options the options to obtain the index for
|
|
||||||
* @param global the number of bindings expected to be found at global scope
|
* @param global the number of bindings expected to be found at global scope
|
||||||
* @param all the number of bindings expected to be found at all scopes
|
* @param all the number of bindings expected to be found at all scopes
|
||||||
* @return
|
* @return the index
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
private IIndex assertBCount(int global, int all) throws CoreException {
|
private IIndex assertBCount(int global, int all) throws CoreException {
|
||||||
|
@ -450,14 +446,15 @@ class ProjectBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectBuilder addFile(String relativePath, StringBuffer content) {
|
ProjectBuilder addFile(String relativePath, CharSequence content) {
|
||||||
path2content.put(relativePath, content.toString());
|
path2content.put(relativePath, content.toString());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICProject create() throws CoreException {
|
ICProject create() throws CoreException {
|
||||||
ICProject result = cpp ? CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER)
|
ICProject result = cpp ?
|
||||||
: CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
|
||||||
|
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
|
||||||
for (Iterator i = path2content.entrySet().iterator(); i.hasNext();) {
|
for (Iterator i = path2content.entrySet().iterator(); i.hasNext();) {
|
||||||
Map.Entry entry = (Map.Entry) i.next();
|
Map.Entry entry = (Map.Entry) i.next();
|
||||||
|
|
|
@ -969,7 +969,7 @@ public class CPPSemantics {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Lookup in base classes
|
// Lookup in base classes
|
||||||
if (!data.usingDirectivesOnly && scope instanceof ICPPClassScope) {
|
if (!data.usingDirectivesOnly && scope instanceof ICPPClassScope && !data.ignoreMembers) {
|
||||||
BaseClassLookup.lookupInBaseClasses(data, (ICPPClassScope) scope, fileSet);
|
BaseClassLookup.lookupInBaseClasses(data, (ICPPClassScope) scope, fileSet);
|
||||||
if (!data.contentAssist && data.hasResultOrProblem())
|
if (!data.contentAssist && data.hasResultOrProblem())
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue