mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
188274: add a testcase for the reported CCE, plus a testcase for a related failure
This commit is contained in:
parent
71189f2253
commit
3840ecf156
3 changed files with 102 additions and 8 deletions
|
@ -397,4 +397,16 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When a test is failing only for the strategy where the test data is split over
|
||||
* multiple index fragements, we artificially fail the single fragment strategy also.
|
||||
* This is not ideal, but as both strategies behaviour are typically the same, is
|
||||
* quite rare.
|
||||
*/
|
||||
protected void fakeFailForSingle() {
|
||||
if(getName().startsWith("_") && strategy instanceof SinglePDOMTestStrategy) {
|
||||
fail("Artificially failing - see IndexBindingResolutionTestBase.fakeFailForSingle()");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
|
@ -28,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalTemplateInstantiator;
|
||||
|
||||
/**
|
||||
* For testing PDOM binding resolution
|
||||
|
@ -37,6 +40,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
public static class SingleProject extends IndexCPPBindingResolutionBugs {
|
||||
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
|
||||
}
|
||||
|
||||
public static class ProjectWithDepProj extends IndexCPPBindingResolutionBugs {
|
||||
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
|
||||
}
|
||||
|
@ -54,11 +58,41 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
setStrategy(new SinglePDOMTestStrategy(true));
|
||||
}
|
||||
|
||||
// template<typename T1>
|
||||
// class A {};
|
||||
//
|
||||
// template<typename T2>
|
||||
// class B : public A<T2> {};
|
||||
//
|
||||
// class C {};
|
||||
//
|
||||
// B<C> b;
|
||||
|
||||
// void foo() {C c; B<int> b;}
|
||||
public void _testBug188274() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("C", 1);
|
||||
IBinding b1= getBindingFromASTName("B", 1);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
assertInstance(b1, ICPPClassType.class);
|
||||
assertInstance(b1, ICPPClassTemplate.class);
|
||||
assertInstance(b1, ICPPInternalTemplateInstantiator.class);
|
||||
|
||||
ICPPInternalTemplateInstantiator ct= (ICPPInternalTemplateInstantiator) b1;
|
||||
ICPPSpecialization inst= ct.getInstance(new IType[]{(IType)b0});
|
||||
assertInstance(inst, ICPPClassType.class);
|
||||
ICPPClassType c2t= (ICPPClassType) inst;
|
||||
ICPPBase[] bases= c2t.getBases();
|
||||
assertEquals(1, bases.length);
|
||||
assertInstance(bases[0].getBaseClass(), ICPPClassType.class);
|
||||
|
||||
fakeFailForSingle();
|
||||
}
|
||||
|
||||
// namespace ns {class A{};}
|
||||
|
||||
// ns::A a;
|
||||
// class B {};
|
||||
public void test188324() throws Exception {
|
||||
public void testBug188324() throws Exception {
|
||||
IASTName name= findNames("B", 1)[0];
|
||||
IBinding b0= getBindingFromASTName("ns::A", 2);
|
||||
assertInstance(b0, ICPPNamespace.class);
|
||||
|
@ -72,7 +106,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// void foo() {
|
||||
// C<int>::unresolvable();
|
||||
// };
|
||||
public void test185828() throws Exception {
|
||||
public void testBug185828() throws Exception {
|
||||
// Bug 185828 reports a StackOverflowException is thrown before we get here.
|
||||
// That the SOE is thrown is detected in BaseTestCase via an Error IStatus
|
||||
|
||||
|
@ -101,10 +135,10 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// };
|
||||
|
||||
// int main() {
|
||||
// MyClass* cls;
|
||||
// MyClass* cls= new MyClass();
|
||||
// }
|
||||
public void test184216() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("MyClass", 7);
|
||||
public void testBug184216() throws Exception {
|
||||
IBinding b0= getBindingFromASTName("MyClass*", 7);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
ICPPClassType ct= (ICPPClassType) b0;
|
||||
ICPPMethod[] ms= ct.getDeclaredMethods(); // 184216 reports CCE thrown
|
||||
|
@ -155,7 +189,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// b.fooovr(1);
|
||||
// b.fooovr('a');
|
||||
// }
|
||||
public void test168020() {
|
||||
public void testBug168020() {
|
||||
getBindingFromASTName("foo(int i)", 3);
|
||||
getBindingFromASTName("fooint()", 6);
|
||||
getBindingFromASTName("fooovr()", 6);
|
||||
|
@ -185,7 +219,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// void Base::foo(int i) {
|
||||
// i=2;
|
||||
// }
|
||||
// void Base::foo2(int j) {
|
||||
// int Base::foo2(int j) {
|
||||
// j=2;
|
||||
// }
|
||||
// void func(int k) {
|
||||
|
@ -194,7 +228,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// void func2(int l) {
|
||||
// l=2;
|
||||
// }
|
||||
public void test168054() {
|
||||
public void testBug168054() {
|
||||
getBindingFromASTName("i=2", 1);
|
||||
getBindingFromASTName("j=2", 1);
|
||||
getBindingFromASTName("k=2", 1);
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
|
@ -258,6 +259,53 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertEquals(3, ct.getPartialSpecializations().length);
|
||||
}
|
||||
|
||||
// template<typename T1>
|
||||
// class A {};
|
||||
//
|
||||
// template<typename T2>
|
||||
// class B : public A<T2> {
|
||||
// public:
|
||||
// static void foo() {}
|
||||
// };
|
||||
//
|
||||
// B<int> bb; // make sure the instance is in the pdom
|
||||
|
||||
// template<typename T3>
|
||||
// class X : public B<T3> {};
|
||||
//
|
||||
// void qux() {
|
||||
// B<int>::foo();
|
||||
// B<long>::foo(); // instance not in the referenced pdom
|
||||
// X<int> x;
|
||||
// }
|
||||
public void _testClassImplicitInstantiations_188274() throws Exception {
|
||||
IBinding b2= getBindingFromASTName("X<int>", 6, true);
|
||||
assertInstance(b2, ICPPClassType.class);
|
||||
assertInstance(b2, ICPPTemplateInstance.class);
|
||||
ICPPClassType ct2= (ICPPClassType) b2;
|
||||
ICPPBase[] bss2= ct2.getBases();
|
||||
assertEquals(1, bss2.length);
|
||||
assertInstance(bss2[0].getBaseClass(), ICPPClassType.class);
|
||||
ICPPClassType ct2b= (ICPPClassType) bss2[0].getBaseClass();
|
||||
assertInstance(ct2b, ICPPTemplateInstance.class);
|
||||
|
||||
IBinding b0= getBindingFromASTName("B<int>", 6, true);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
ICPPClassType ct= (ICPPClassType) b0;
|
||||
ICPPBase[] bss= ct.getBases();
|
||||
assertEquals(1, bss.length);
|
||||
assertInstance(bss[0].getBaseClass(), ICPPClassType.class);
|
||||
|
||||
IBinding b1= getBindingFromASTName("B<long>", 7, true);
|
||||
assertInstance(b1, ICPPClassType.class);
|
||||
ICPPClassType ct1= (ICPPClassType) b1;
|
||||
ICPPBase[] bss1= ct1.getBases();
|
||||
assertEquals(1, bss1.length);
|
||||
assertInstance(bss1[0].getBaseClass(), ICPPClassType.class);
|
||||
|
||||
fakeFailForSingle();
|
||||
}
|
||||
|
||||
// class B {};
|
||||
//
|
||||
// template<typename T>
|
||||
|
|
Loading…
Add table
Reference in a new issue