diff options
author | Sergey Prigogin | 2012-06-05 17:31:26 +0000 |
---|---|---|
committer | Sergey Prigogin | 2012-06-27 01:40:33 +0000 |
commit | c67276494e8d767e9576ca8e01e2b84a605bdfaf (patch) | |
tree | f03f39cd08664a3057fcaf9e7a3ecc838b5ee308 | |
parent | a2f501987dad996835b2245524ea02632698d597 (diff) | |
download | org.eclipse.cdt-c67276494e8d767e9576ca8e01e2b84a605bdfaf.tar.gz org.eclipse.cdt-c67276494e8d767e9576ca8e01e2b84a605bdfaf.tar.xz org.eclipse.cdt-c67276494e8d767e9576ca8e01e2b84a605bdfaf.zip |
Cosmetics.
7 files changed, 1131 insertions, 1120 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 7e5f834f080..043614ad7eb 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -90,14 +90,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; public class AST2TemplateTests extends AST2BaseTest { - + public AST2TemplateTests() { } - + public AST2TemplateTests(String name) { super(name); } - + public static TestSuite suite() { return suite(AST2TemplateTests.class); } @@ -114,151 +114,151 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse("template <class T> class A{ T t; };", ParserLanguage.CPP); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertEquals(col.size(), 4); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); - + ICPPTemplateScope scope = (ICPPTemplateScope) T.getScope(); IScope s2 = A.getScope(); assertSame(scope, s2); - + ICPPField t = (ICPPField) col.getName(3).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding(); - + assertSame(T, T2); IType type = t.getType(); assertSame(type, T); - + assertNotNull(T); assertNotNull(A); } - - // template < class T > class A { - // T t1; - // T * t2; - // }; - // void f(){ - // A<int> a; - // a.t1; a.t2; - // } + + // template < class T > class A { + // T t1; + // T * t2; + // }; + // void f(){ + // A<int> a; + // a.t1; a.t2; + // } public void testBasicTemplateInstance_1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertEquals(col.size(), 14); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPField t1 = (ICPPField) col.getName(3).resolveBinding(); ICPPField t2 = (ICPPField) col.getName(5).resolveBinding(); - + assertSame(t1.getType(), T); - assertSame(((IPointerType)t2.getType()).getType(), T); - + assertSame(((IPointerType) t2.getType()).getType(), T); + ICPPVariable a = (ICPPVariable) col.getName(9).resolveBinding(); - + ICPPClassType A_int = (ICPPClassType) col.getName(7).resolveBinding(); assertSame(A_int, a.getType()); - + assertTrue(A_int instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A); - + ICPPClassScope A_int_Scope = (ICPPClassScope) A_int.getCompositeScope(); assertNotSame(A_int_Scope, ((ICompositeType) A).getCompositeScope()); - + ICPPField t = (ICPPField) col.getName(11).resolveBinding(); assertTrue(t instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)t).getSpecializedBinding(), t1); + assertSame(((ICPPSpecialization) t).getSpecializedBinding(), t1); assertSame(t.getScope(), A_int_Scope); IType type = t.getType(); assertTrue(type instanceof IBasicType); - assertEquals(((IBasicType)type).getType(), IBasicType.t_int); - + assertEquals(((IBasicType) type).getType(), IBasicType.t_int); + t = (ICPPField) col.getName(13).resolveBinding(); assertTrue(t instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)t).getSpecializedBinding(), t2); + assertSame(((ICPPSpecialization) t).getSpecializedBinding(), t2); assertSame(t.getScope(), A_int_Scope); type = t.getType(); assertTrue(type instanceof IPointerType); - assertTrue(((IPointerType)type).getType() instanceof IBasicType); - assertEquals(((IBasicType)((IPointerType)type).getType()).getType(), IBasicType.t_int); - } - - // template < class T > class A { - // T f(T *); - // }; - // void g(){ - // A<int> a; - // a.f((int*)0); - // } + assertTrue(((IPointerType) type).getType() instanceof IBasicType); + assertEquals(((IBasicType) ((IPointerType) type).getType()).getType(), IBasicType.t_int); + } + + // template < class T > class A { + // T f(T *); + // }; + // void g(){ + // A<int> a; + // a.f((int*)0); + // } public void testBasicTemplateInstance_2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(3).resolveBinding(); IFunctionType ft = f.getType(); - + assertSame(ft.getReturnType(), T); - assertSame(((IPointerType)ft.getParameterTypes()[0]).getType(), T); - + assertSame(((IPointerType) ft.getParameterTypes()[0]).getType(), T); + ICPPClassType A_int = (ICPPClassType) col.getName(7).resolveBinding(); assertTrue(A_int instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A_int).getTemplateDefinition(), A); - + ICPPMethod f_int = (ICPPMethod) col.getName(11).resolveBinding(); assertTrue(f_int instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)f_int).getSpecializedBinding(), f); + assertSame(((ICPPSpecialization) f_int).getSpecializedBinding(), f); ft = f_int.getType(); assertTrue(ft.getReturnType() instanceof IBasicType); - assertTrue(((IPointerType)ft.getParameterTypes()[0]).getType() instanceof IBasicType); - } - - // template <class T > void f(T); - // template <class T > void f(T) { - // T * d; - // } - // void foo() { - // f<int>(0); - // } + assertTrue(((IPointerType) ft.getParameterTypes()[0]).getType() instanceof IBasicType); + } + + // template <class T > void f(T); + // template <class T > void f(T) { + // T * d; + // } + // void foo() { + // f<int>(0); + // } public void testBasicTemplateFunction() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); - + IParameter p1 = (IParameter) col.getName(3).resolveBinding(); - + ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(4).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(5).resolveBinding(); IParameter p2 = (IParameter) col.getName(7).resolveBinding(); - + assertSame(T, T2); assertSame(f, f2); assertSame(p1, p2); assertSame(p1.getType(), T); - + ICPPFunction f3 = (ICPPFunction) col.getName(11).resolveBinding(); assertTrue(f3 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)f3).getTemplateDefinition(), f); - + assertSame(((ICPPTemplateInstance) f3).getTemplateDefinition(), f); + assertInstances(col, T, 5); } - - // template < class T > class pair { - // template < class U > pair(const pair<U> &); - // }; + + // template < class T > class pair { + // template < class U > pair(const pair<U> &); + // }; public void testStackOverflow() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertTrue(col.getName(0).resolveBinding() instanceof ICPPTemplateParameter); ICPPClassTemplate pair = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(2).resolveBinding(); @@ -266,20 +266,20 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateInstance pi = (ICPPTemplateInstance) col.getName(4).resolveBinding(); ICPPClassTemplate p = (ICPPClassTemplate) col.getName(5).resolveBinding(); ICPPTemplateParameter U2 = (ICPPTemplateParameter) col.getName(6).resolveBinding(); - + assertSame(U, U2); assertSame(pair, p); assertSame(pi.getTemplateDefinition(), pair); } - - // template < class T > class A {}; - // template < class T > class A< T* > {}; - // template < class T > class A< T** > {}; + + // template < class T > class A {}; + // template < class T > class A< T* > {}; + // template < class T > class A< T** > {}; public void testBasicClassPartialSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding(); @@ -287,7 +287,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateParameter T3 = (ICPPTemplateParameter) col.getName(5).resolveBinding(); ICPPClassTemplatePartialSpecialization A3 = (ICPPClassTemplatePartialSpecialization) col.getName(7).resolveBinding(); ICPPTemplateParameter T4 = (ICPPTemplateParameter) col.getName(6).resolveBinding(); - + assertSame(A2.getPrimaryClassTemplate(), A1); assertSame(A3.getPrimaryClassTemplate(), A1); assertNotSame(T1, T2); @@ -297,1005 +297,1005 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(T2, T3); assertNotSame(T2, T4); } - - // template < class T > class A { typedef int TYPE; }; - // template < class T > typename A<T>::TYPE foo(T); - // template < class T > typename A<T>::TYPE foo(T); + + // template < class T > class A { typedef int TYPE; }; + // template < class T > typename A<T>::TYPE foo(T); + // template < class T > typename A<T>::TYPE foo(T); public void testStackOverflow_2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T0 = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(12).resolveBinding(); - + assertNotSame(T0, T1); assertSame(T1, T2); - + ICPPFunctionTemplate foo1 = (ICPPFunctionTemplate) col.getName(9).resolveBinding(); ICPPFunctionTemplate foo2 = (ICPPFunctionTemplate) col.getName(18).resolveBinding(); assertSame(foo1, foo2); - + ITypedef TYPE = (ITypedef) col.getName(2).resolveBinding(); IBinding b0 = col.getName(8).resolveBinding(); IBinding b1 = col.getName(17).resolveBinding(); assertSame(b1, b0); - + // the instantiation of A<T> has to be deferred. assertInstance(b0, ICPPUnknownBinding.class); - final ICPPBinding parent = ((ICPPInternalUnknownScope)b0.getScope()).getScopeBinding(); + final ICPPBinding parent = ((ICPPInternalUnknownScope) b0.getScope()).getScopeBinding(); assertInstance(parent, ICPPDeferredClassInstance.class); assertSame(((ICPPDeferredClassInstance) parent).getSpecializedBinding(), A); assertInstances(col, T1, 6); } - - // template < class T > class A { - // void f(); - // }; - // template < class T > void A<T>::f() { } + + // template < class T > class A { + // void f(); + // }; + // template < class T > void A<T>::f() { } public void testTemplateMemberDef() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(8).resolveBinding(); - + assertSame(f2, f1); } - - // template < class T > void f (T); - // void main() { - // f(1); - // } + + // template < class T > void f (T); + // void main() { + // f(1); + // } public void testTemplateFunctionImplicitInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); IFunction f2 = (IFunction) col.getName(5).resolveBinding(); - + assertTrue(f2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f1); + assertSame(((ICPPTemplateInstance) f2).getTemplateDefinition(), f1); } - - // template < class T > void f(T); // #1 + + // template < class T > void f(T); // #1 // template < class T > void f(T*); // #2 - // template < class T > void f(const T*); // #3 - // void main() { - // const int *p; + // template < class T > void f(const T*); // #3 + // void main() { + // const int *p; // f(p); //calls f(const T *) , 3 is more specialized than 1 or 2 - // } + // } public void test_14_5_5_2s5_OrderingFunctionTemplates_1() throws Exception{ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate f2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); ICPPFunctionTemplate f3 = (ICPPFunctionTemplate) col.getName(9).resolveBinding(); - + assertNotSame(f1, f2); assertNotSame(f2, f3); assertNotSame(f3, f1); - + IFunction f = (IFunction) col.getName(14).resolveBinding(); assertTrue(f instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)f).getTemplateDefinition(), f3); + assertSame(((ICPPTemplateInstance) f).getTemplateDefinition(), f3); } - + // template < class T > void f(T); // #1 // template < class T > void f(T&); // #2 - // void main() { - // float x; + // void main() { + // float x; // f(x); //ambiguous 1 or 2 - // } + // } public void test_14_5_5_2s5_OrderingFunctionTemplates_2() throws Exception{ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate f2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); - + assertNotSame(f1, f2); - + IProblemBinding f = (IProblemBinding) col.getName(10).resolveBinding(); assertEquals(f.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP); } - - // template < class T, template < class X > class U, T *pT > class A { - // }; + + // template < class T, template < class X > class U, T *pT > class A { + // }; public void testTemplateParameters() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding(); ICPPTemplateTemplateParameter U = (ICPPTemplateTemplateParameter) col.getName(2).resolveBinding(); ICPPTemplateNonTypeParameter pT = (ICPPTemplateNonTypeParameter) col.getName(4).resolveBinding(); - + ICPPTemplateTypeParameter X = (ICPPTemplateTypeParameter) col.getName(1).resolveBinding(); - + ICPPTemplateParameter[] ps = U.getTemplateParameters(); assertEquals(ps.length, 1); assertSame(ps[0], X); - + IPointerType ptype = (IPointerType) pT.getType(); assertSame(ptype.getType(), T); } - - // template <class T> class A { - // A<T>* a; - // A<T>* a2; - // }; - // void f(){ - // A<int> * b; - // b->a; - // } + + // template <class T> class A { + // A<T>* a; + // A<T>* a2; + // }; + // void f(){ + // A<int> * b; + // b->a; + // } public void testDeferredInstances() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPTemplateInstance A_T = (ICPPTemplateInstance) col.getName(2).resolveBinding(); assertSame(A_T.getTemplateDefinition(), A); - + ICPPTemplateInstance A_T2 = (ICPPTemplateInstance) col.getName(6).resolveBinding(); assertSame(A_T, A_T2); - + ICPPVariable a = (ICPPVariable) col.getName(5).resolveBinding(); IPointerType pt = (IPointerType) a.getType(); assertSame(pt.getType(), A_T); - + ICPPVariable b = (ICPPVariable) col.getName(13).resolveBinding(); IType bt = b.getType(); assertTrue(bt instanceof IPointerType); - + ICPPVariable a2 = (ICPPVariable) col.getName(15).resolveBinding(); assertTrue(a2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)a2).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization) a2).getSpecializedBinding(), a); IType at = a2.getType(); assertTrue(at instanceof IPointerType); - - assertSame(((IPointerType)at).getType(), ((IPointerType)bt).getType()); - } - - // template < class T1, class T2, int I > class A {}; //#1 - // template < class T, int I > class A < T, T*, I > {}; //#2 - // template < class T1, class T2, int I > class A < T1*, T2, I > {}; //#3 - // template < class T > class A < int, T*, 5 > {}; //#4 - // template < class T1, class T2, int I > class A < T1, T2*, I > {}; //#5 - // - // A <int, int, 1> a1; //uses #1 - // A <int, int*, 1> a2; //uses #2, T is int, I is 1 - // A <int, char*, 5> a3; //uses #4, T is char - // A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1 - // A <int*, int*, 2> a5; //ambiguous, matches #3 & #5. + + assertSame(((IPointerType) at).getType(), ((IPointerType) bt).getType()); + } + + // template < class T1, class T2, int I > class A {}; //#1 + // template < class T, int I > class A < T, T*, I > {}; //#2 + // template < class T1, class T2, int I > class A < T1*, T2, I > {}; //#3 + // template < class T > class A < int, T*, 5 > {}; //#4 + // template < class T1, class T2, int I > class A < T1, T2*, I > {}; //#5 + // + // A <int, int, 1> a1; //uses #1 + // A <int, int*, 1> a2; //uses #2, T is int, I is 1 + // A <int, char*, 5> a3; //uses #4, T is char + // A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1 + // A <int*, int*, 2> a5; //ambiguous, matches #3 & #5. public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPClassTemplate A2 = (ICPPClassTemplate) col.getName(6).resolveBinding(); ICPPClassTemplate A3 = (ICPPClassTemplate) col.getName(14).resolveBinding(); ICPPClassTemplate A4 = (ICPPClassTemplate) col.getName(20).resolveBinding(); ICPPClassTemplate A5 = (ICPPClassTemplate) col.getName(26).resolveBinding(); - + assertTrue(A3 instanceof ICPPClassTemplatePartialSpecialization); assertSame(((ICPPClassTemplatePartialSpecialization)A3).getPrimaryClassTemplate(), A1); - + ICPPTemplateTypeParameter T1 = (ICPPTemplateTypeParameter) col.getName(11).resolveBinding(); ICPPTemplateTypeParameter T2 = (ICPPTemplateTypeParameter) col.getName(12).resolveBinding(); ICPPTemplateNonTypeParameter I = (ICPPTemplateNonTypeParameter) col.getName(13).resolveBinding(); - + ICPPTemplateParameter TR1 = (ICPPTemplateParameter) col.getName(16).resolveBinding(); ICPPTemplateParameter TR2 = (ICPPTemplateParameter) col.getName(17).resolveBinding(); ICPPTemplateParameter TR3 = (ICPPTemplateParameter) col.getName(18).resolveBinding(); - + assertSame(T1, TR1); assertSame(T2, TR2); assertSame(I, TR3); - + ICPPTemplateInstance R1 = (ICPPTemplateInstance) col.getName(31).resolveBinding(); ICPPTemplateInstance R2 = (ICPPTemplateInstance) col.getName(34).resolveBinding(); ICPPTemplateInstance R3 = (ICPPTemplateInstance) col.getName(37).resolveBinding(); ICPPTemplateInstance R4 = (ICPPTemplateInstance) col.getName(40).resolveBinding(); IProblemBinding R5 = (IProblemBinding) col.getName(43).resolveBinding(); assertEquals(R5.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP); - + assertSame(R1.getTemplateDefinition(), A1); assertSame(R2.getTemplateDefinition(), A2); assertSame(R4.getTemplateDefinition(), A5); assertSame(R3.getTemplateDefinition(), A4); } - - // template <class T> void f(T); - // template <class T> void f(T*); - // template <> void f(int); //ok - // template <> void f<int>(int*); //ok + + // template <class T> void f(T); + // template <class T> void f(T*); + // template <> void f(int); //ok + // template <> void f<int>(int*); //ok public void test14_7_3_FunctionExplicitSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate fT1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate fT2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); - + ICPPSpecialization f1 = (ICPPSpecialization) col.getName(8).resolveBinding(); ICPPSpecialization f2 = (ICPPSpecialization) col.getName(10).resolveBinding(); - + assertSame(f1.getSpecializedBinding(), fT1); assertSame(f2.getSpecializedBinding(), fT2); } - - // template<class T> void f(T*); - // void g(int* p) { f(p); } + + // template<class T> void f(T*); + // void g(int* p) { f(p); } public void test_14_5_5_1_FunctionTemplates_1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); - + ICPPFunction ref = (ICPPFunction) col.getName(6).resolveBinding(); assertTrue(ref instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)ref).getTemplateDefinition(), f); + assertSame(((ICPPTemplateInstance) ref).getTemplateDefinition(), f); } - - // template<class T> void f(T); - // void g(int* p) { f(p); } + + // template<class T> void f(T); + // void g(int* p) { f(p); } public void test_14_5_5_1_FunctionTemplates_2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); - + ICPPFunction ref = (ICPPFunction) col.getName(6).resolveBinding(); assertTrue(ref instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)ref).getTemplateDefinition(), f); + assertSame(((ICPPTemplateInstance) ref).getTemplateDefinition(), f); } - - // template<class X, class Y> X f(Y); - // void g(){ - // int i = f<int>(5); // Y is int - // } + + // template<class X, class Y> X f(Y); + // void g(){ + // int i = f<int>(5); // Y is int + // } public void test_14_8_1s2_FunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(3).resolveBinding(); ICPPFunction ref1 = (ICPPFunction) col.getName(8).resolveBinding(); - + assertTrue(ref1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance) ref1).getTemplateDefinition(), f); } - - // template<class T> void f(T); - // void g(){ - // f("Annemarie"); - // } + + // template<class T> void f(T); + // void g(){ + // f("Annemarie"); + // } public void test14_8_3s6_FunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction ref = (ICPPFunction) col.getName(5).resolveBinding(); assertTrue(ref instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)ref).getTemplateDefinition(), f); + assertSame(((ICPPTemplateInstance) ref).getTemplateDefinition(), f); } - + // template<class T> void f(T); // #1 // template<class T> void f(T*, int=1); // #2 // template<class T> void g(T); // #3 // template<class T> void g(T*, ...); // #4 - // int main() { - // int* ip; + // int main() { + // int* ip; // f(ip); //calls #2 // g(ip); //calls #4 - // } + // } public void test14_5_5_2s6_FunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate f2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); assertNotSame(f1, f2); - + ICPPFunctionTemplate g1 = (ICPPFunctionTemplate) col.getName(10).resolveBinding(); ICPPFunctionTemplate g2 = (ICPPFunctionTemplate) col.getName(14).resolveBinding(); assertNotSame(g1, g2); - + ICPPFunction ref1 = (ICPPFunction) col.getName(19).resolveBinding(); ICPPFunction ref2 = (ICPPFunction) col.getName(21).resolveBinding(); - + assertTrue(ref1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance) ref1).getTemplateDefinition(), f2); - + assertTrue(ref2 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance) ref2).getTemplateDefinition(), g2); } - - // template<class T> class X { + + // template<class T> class X { // X* p; // meaning X<T> - // X<T>* p2; - // }; + // X<T>* p2; + // }; public void test14_6_1s1_LocalNames() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate X = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType x1 = (ICPPClassType) col.getName(2).resolveBinding(); ICPPClassType x2 = (ICPPClassType) col.getName(4).resolveBinding(); - + assertTrue(x1 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)x1).getTemplateDefinition(), X); - + assertSame(((ICPPTemplateInstance) x1).getTemplateDefinition(), X); + assertSame(x1, x2); } - - // template<class T> T f(T* p){ - // }; - // void g(int a, char* b){ - // f(&a); //call f<int>(int*) + + // template<class T> T f(T* p){ + // }; + // void g(int a, char* b){ + // f(&a); //call f<int>(int*) // f(&b); //call f<char*>(char**) - // } + // } public void test14_8s2_() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(2).resolveBinding(); - + ICPPFunction f1 = (ICPPFunction) col.getName(8).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(10).resolveBinding(); - + assertNotSame(f1, f2); assertTrue(f1 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)f1).getTemplateDefinition(), f); + assertSame(((ICPPTemplateInstance) f1).getTemplateDefinition(), f); assertTrue(f2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f); - + assertSame(((ICPPTemplateInstance) f2).getTemplateDefinition(), f); + IType fr1 = f1.getType().getReturnType(); IType fr2 = f2.getType().getReturnType(); - + assertTrue(fr1 instanceof IBasicType); - assertEquals(((IBasicType)fr1).getType(), IBasicType.t_int); - + assertEquals(((IBasicType) fr1).getType(), IBasicType.t_int); + assertTrue(fr2 instanceof IPointerType); - assertTrue(((IPointerType)fr2).getType() instanceof IBasicType); - assertEquals(((IBasicType) ((IPointerType)fr2).getType()).getType(), IBasicType.t_char); + assertTrue(((IPointerType) fr2).getType() instanceof IBasicType); + assertEquals(((IBasicType) ((IPointerType) fr2).getType()).getType(), IBasicType.t_char); } - - // template<class T> void f(T) { } - // template<class T> inline T g(T) { } - // template<> inline void f<>(int) { } //OK: inline + + // template<class T> void f(T) { } + // template<class T> inline T g(T) { } + // template<> inline void f<>(int) { } //OK: inline // template<> int g<>(int) { } // OK: not inline public void test14_7_3s14() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate g1 = (ICPPFunctionTemplate) col.getName(6).resolveBinding(); - + ICPPSpecialization f2 = (ICPPSpecialization) col.getName(9).resolveBinding(); ICPPSpecialization g2 = (ICPPSpecialization) col.getName(12).resolveBinding(); - + assertSame(f2.getSpecializedBinding(), f1); assertSame(g2.getSpecializedBinding(), g1); - - assertFalse(((ICPPFunction)f1).isInline()); - assertTrue(((ICPPFunction)g1).isInline()); - assertTrue(((ICPPFunction)f2).isInline()); - assertFalse(((ICPPFunction)g2).isInline()); - } - - // template<class T> class X { - // X<T*> a; // implicit generation of X<T> requires - // // the implicit instantiation of X<T*> which requires - // // the implicit instantiation of X<T**> which ... - // }; - // void f() { - // X<int> x; - // x.a.a.a.a; - // } + + assertFalse(((ICPPFunction) f1).isInline()); + assertTrue(((ICPPFunction) g1).isInline()); + assertTrue(((ICPPFunction) f2).isInline()); + assertFalse(((ICPPFunction) g2).isInline()); + } + + // template<class T> class X { + // X<T*> a; // implicit generation of X<T> requires + // // the implicit instantiation of X<T*> which requires + // // the implicit instantiation of X<T**> which ... + // }; + // void f() { + // X<int> x; + // x.a.a.a.a; + // } public void test14_7_1s14_InfiniteInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate X = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPVariable x = (ICPPVariable) col.getName(9).resolveBinding(); IType t = x.getType(); assertTrue(t instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance) t).getTemplateDefinition(), X); - + ICPPField a = (ICPPField) col.getName(5).resolveBinding(); ICPPField a1 = (ICPPField) col.getName(11).resolveBinding(); ICPPField a2 = (ICPPField) col.getName(12).resolveBinding(); ICPPField a3 = (ICPPField) col.getName(13).resolveBinding(); ICPPField a4 = (ICPPField) col.getName(14).resolveBinding(); - + assertTrue(a1 instanceof ICPPSpecialization); assertTrue(a2 instanceof ICPPSpecialization); assertTrue(a3 instanceof ICPPSpecialization); assertTrue(a4 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)a1).getSpecializedBinding(), a); - assertSame(((ICPPSpecialization)a2).getSpecializedBinding(), a); - assertSame(((ICPPSpecialization)a3).getSpecializedBinding(), a); - assertSame(((ICPPSpecialization)a4).getSpecializedBinding(), a); - } - - // template<class T> class Y; - // template<> class Y<int> { - // Y* p; // meaning Y<int> - // Y<char>* q; // meaning Y<char> - // }; + assertSame(((ICPPSpecialization) a1).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization) a2).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization) a3).getSpecializedBinding(), a); + assertSame(((ICPPSpecialization) a4).getSpecializedBinding(), a); + } + + // template<class T> class Y; + // template<> class Y<int> { + // Y* p; // meaning Y<int> + // Y<char>* q; // meaning Y<char> + // }; public void test14_6_1s2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate Y = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPSpecialization Yspec = (ICPPSpecialization) col.getName(2).resolveBinding(); - + assertTrue(Yspec instanceof ICPPClassType); assertSame(Yspec.getSpecializedBinding(), Y); - + ICPPClassType y1 = (ICPPClassType) col.getName(4).resolveBinding(); assertSame(y1, Yspec); - + ICPPClassType y2 = (ICPPClassType) col.getName(6).resolveBinding(); assertTrue(y2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)y2).getTemplateDefinition(), Y); - } - - // template < class T, class U > void f (T (*) (T, U)); - // int g (int, char); - // void foo () { - // f(g); - // } + assertSame(((ICPPTemplateInstance) y2).getTemplateDefinition(), Y); + } + + // template < class T, class U > void f (T (*) (T, U)); + // int g (int, char); + // void foo () { + // f(g); + // } public void testBug45129() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunction f1 = (ICPPFunction) col.getName(2).resolveBinding(); ICPPFunction g1 = (ICPPFunction) col.getName(9).resolveBinding(); - + IBinding f2 = col.getName(13).resolveBinding(); IBinding g2 = col.getName(14).resolveBinding(); - + assertTrue(f2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)f2).getTemplateDefinition(), f1); + assertSame(((ICPPTemplateInstance) f2).getTemplateDefinition(), f1); assertSame(g1, g2); } - - // template <class T, class U = T > class A { - // U u; - // }; - // void f() { - // A<int> a; - // a.u; - // } + + // template <class T, class U = T > class A { + // U u; + // }; + // void f() { + // A<int> a; + // a.u; + // } public void testBug76951_2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateTypeParameter U = (ICPPTemplateTypeParameter) col.getName(1).resolveBinding(); assertSame(U.getDefault(), T); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPField u1 = (ICPPField) col.getName(5).resolveBinding(); assertSame(u1.getType(), U); - + ICPPClassType A1 = (ICPPClassType) col.getName(7).resolveBinding(); assertTrue(A1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); - + ICPPField u2 = (ICPPField) col.getName(11).resolveBinding(); assertTrue(u2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)u2).getSpecializedBinding(), u1); - + assertSame(((ICPPSpecialization) u2).getSpecializedBinding(), u1); + IType type = u2.getType(); assertTrue(type instanceof IBasicType); - assertEquals(((IBasicType)type).getType(), IBasicType.t_int); + assertEquals(((IBasicType) type).getType(), IBasicType.t_int); } - - // template < class T > class A { - // A< int > a; - // }; - // void f(A<int> p) { } + + // template < class T > class A { + // A< int > a; + // }; + // void f(A<int> p) { } public void testInstances() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A1 = (ICPPClassType) col.getName(2).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(6).resolveBinding(); - + assertSame(A1, A2); assertTrue(A1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); } - - // template <class T> void f(T); - // template <class T> void f(T) {} + + // template <class T> void f(T); + // template <class T> void f(T) {} public void testTemplateParameterDeclarations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T1 = (ICPPTemplateParameter) col.getName(4).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(2).resolveBinding(); - + assertSame(T1, T2); - + assertInstances(col, T1, 4); } - - // template < class T > class A { - // int f(A *); - // A < T > *pA; - // }; - // void f () { - // A< int > *a; - // a->f(a); - // a->pA; - // }; + + // template < class T > class A { + // int f(A *); + // A < T > *pA; + // }; + // void f () { + // A< int > *a; + // a->f(a); + // a->pA; + // }; public void testDeferredInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(2).resolveBinding(); ICPPClassType A1 = (ICPPClassType) col.getName(3).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding(); ICPPField pA = (ICPPField) col.getName(8).resolveBinding(); - + assertSame(A1, A2); assertTrue(A1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); - + ICPPClassType AI = (ICPPClassType) col.getName(10).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(14).resolveBinding(); ICPPField pA2 = (ICPPField) col.getName(17).resolveBinding(); - + assertTrue(f2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f); + assertSame(((ICPPSpecialization) f2).getSpecializedBinding(), f); assertTrue(pA2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)pA2).getSpecializedBinding(), pA); - + assertSame(((ICPPSpecialization) pA2).getSpecializedBinding(), pA); + IType paT = pA2.getType(); assertTrue(paT instanceof IPointerType); - assertSame(((IPointerType)paT).getType(), AI); - + assertSame(((IPointerType) paT).getType(), AI); + IParameter p = f2.getParameters()[0]; IType pT = p.getType(); assertTrue(pT instanceof IPointerType); - assertSame(((IPointerType)pT).getType(), AI); - } - - // template <class T> struct A { - // void f(int); - // template <class T2> void f(T2); - // }; - // template <> void A<int>::f(int) { } //nontemplate - // template <> template <> void A<int>::f<>(int) { } //template - // int main() { - // A<int> ac; - // ac.f(1); //nontemplate - // ac.f('c'); //template - // ac.f<>(1); //template - // } + assertSame(((IPointerType) pT).getType(), AI); + } + + // template <class T> struct A { + // void f(int); + // template <class T2> void f(T2); + // }; + // template <> void A<int>::f(int) { } //nontemplate + // template <> template <> void A<int>::f<>(int) { } //template + // int main() { + // A<int> ac; + // ac.f(1); //nontemplate + // ac.f('c'); //template + // ac.f<>(1); //template + // } public void test14_5_2s2_MemberSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding(); ICPPMethod f2 = (ICPPMethod) col.getName(5).resolveBinding(); - + ICPPMethod f1_2 = (ICPPMethod) col.getName(11).resolveBinding(); assertNotSame(f1, f1_2); assertTrue(f1_2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)f1_2).getSpecializedBinding(), f1); - + assertSame(((ICPPSpecialization) f1_2).getSpecializedBinding(), f1); + ICPPClassType A2 = (ICPPClassType) col.getName(9).resolveBinding(); assertTrue(A2 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A); - + ICPPMethod f2_2 = (ICPPMethod) col.getName(16).resolveBinding(); assertTrue(f2_2 instanceof ICPPSpecialization); - IBinding speced = ((ICPPSpecialization)f2_2).getSpecializedBinding(); + IBinding speced = ((ICPPSpecialization) f2_2).getSpecializedBinding(); assertTrue(speced instanceof ICPPFunctionTemplate && speced instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)speced).getSpecializedBinding(), f2); - + assertSame(((ICPPSpecialization) speced).getSpecializedBinding(), f2); + ICPPClassType A3 = (ICPPClassType) col.getName(14).resolveBinding(); assertSame(A2, A3); - + ICPPClassType A4 = (ICPPClassType) col.getName(20).resolveBinding(); assertSame(A2, A4); - + IFunction r1 = (IFunction) col.getName(24).resolveBinding(); IFunction r2 = (IFunction) col.getName(26).resolveBinding(); IFunction r3 = (IFunction) col.getName(28).resolveBinding(); - + assertSame(r1, f1_2); assertTrue(r2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)r2).getTemplateDefinition(), speced); + assertSame(((ICPPTemplateInstance) r2).getTemplateDefinition(), speced); assertSame(r3, f2_2); } - - // template <class T> class A { }; - // template <> class A<int> {}; - // A<char> ac; - // A<int> ai; + + // template <class T> class A { }; + // template <> class A<int> {}; + // A<char> ac; + // A<int> ai; public void testClassSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); - + assertTrue(A2 instanceof ICPPSpecialization); assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1); - + ICPPClassType r1 = (ICPPClassType) col.getName(4).resolveBinding(); ICPPClassType r2 = (ICPPClassType) col.getName(7).resolveBinding(); - + assertTrue(r1 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)r1).getTemplateDefinition(), A1); + assertSame(((ICPPTemplateInstance) r1).getTemplateDefinition(), A1); assertSame(r2, A2); } - - // template<class T> struct A { - // void f(T) { } - // }; - // template<> struct A<int> { - // void f(int); - // }; - // void h(){ - // A<int> a; - // a.f(16); // A<int>::f must be defined somewhere - // } - // // explicit specialization syntax not used for a member of - // // explicitly specialized class template specialization - // void A<int>::f(int) { } + + // template<class T> struct A { + // void f(T) { } + // }; + // template<> struct A<int> { + // void f(int); + // }; + // void h(){ + // A<int> a; + // a.f(16); // A<int>::f must be defined somewhere + // } + // // explicit specialization syntax not used for a member of + // // explicitly specialized class template specialization + // void A<int>::f(int) { } public void test14_7_3s5_SpecializationMemberDefinition() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding(); - + ICPPClassType A2 = (ICPPClassType) col.getName(5).resolveBinding(); assertTrue(A2 instanceof ICPPSpecialization); assertSame(((ICPPSpecialization)A2).getSpecializedBinding(), A1); - + ICPPMethod f2 = (ICPPMethod) col.getName(7).resolveBinding(); assertNotSame(f1, f2); - + ICPPClassType A3 = (ICPPClassType) col.getName(10).resolveBinding(); assertSame(A3, A2); ICPPMethod f3 = (ICPPMethod) col.getName(14).resolveBinding(); assertSame(f3, f2); - + ICPPClassType A4 = (ICPPClassType) col.getName(16).resolveBinding(); assertSame(A4, A2); ICPPMethod f4 = (ICPPMethod) col.getName(18).resolveBinding(); assertSame(f4, f3); } - - // class C{}; - // template <class T> class A { - // template <class T2> class B { - // T f(T2); - // }; - // }; - // void g(){ - // A<int>::B<C> b; - // C c; - // b.f(c); - // } + + // class C{}; + // template <class T> class A { + // template <class T2> class B { + // T f(T2); + // }; + // }; + // void g(){ + // A<int>::B<C> b; + // C c; + // b.f(c); + // } public void testNestedSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassType C = (ICPPClassType) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(2).resolveBinding(); ICPPClassTemplate B = (ICPPClassTemplate) col.getName(4).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(6).resolveBinding(); - + ICPPClassType A1 = (ICPPClassType) col.getName(11).resolveBinding(); assertTrue(A1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A1).getTemplateDefinition(), A); - + ICPPClassType B1 = (ICPPClassType) col.getName(13).resolveBinding(); assertTrue(B1 instanceof ICPPTemplateInstance); ICPPClassType B2 = (ICPPClassType) ((ICPPTemplateInstance)B1).getTemplateDefinition(); assertTrue(B2 instanceof ICPPSpecialization); assertSame(((ICPPSpecialization)B2).getSpecializedBinding(), B); - + ICPPMethod f1 = (ICPPMethod) col.getName(20).resolveBinding(); assertTrue(f1 instanceof ICPPSpecialization); - assertTrue(((ICPPSpecialization)f1).getSpecializedBinding() instanceof ICPPMethod); - ICPPMethod f2 = (ICPPMethod) ((ICPPSpecialization)f1).getSpecializedBinding(); + assertTrue(((ICPPSpecialization) f1).getSpecializedBinding() instanceof ICPPMethod); + ICPPMethod f2 = (ICPPMethod) ((ICPPSpecialization) f1).getSpecializedBinding(); assertTrue(f2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f); - + assertSame(((ICPPSpecialization) f2).getSpecializedBinding(), f); + IFunctionType ft = f1.getType(); assertTrue(ft.getReturnType() instanceof IBasicType); - assertEquals(((IBasicType)ft.getReturnType()).getType(), IBasicType.t_int); - + assertEquals(((IBasicType) ft.getReturnType()).getType(), IBasicType.t_int); + assertSame(ft.getParameterTypes()[0], C); } - - // namespace N { - // template<class T1, class T2> class A { }; - // } - // using N::A; - // namespace N { - // template<class T> class A<T, T*> { }; - // } - // A<int,int*> a; + + // namespace N { + // template<class T1, class T2> class A { }; + // } + // using N::A; + // namespace N { + // template<class T> class A<T, T*> { }; + // } + // A<int,int*> a; public void test14_5_4s7_UsingClassTemplate() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(9).resolveBinding(); - + ICPPClassType A3 = (ICPPClassType) col.getName(13).resolveBinding(); assertTrue(A3 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A2); - + ICPPClassTemplate A4 = (ICPPClassTemplate) col.getName(14).resolveBinding(); assertSame(A4, A1); } - - // template<class T> class A { - // int x; - // }; - // template<class T> class A<T*> { - // char x; - // }; - // template<template<class U> class V> class C { - // V<int> y; - // V<int*> z; - // }; - // void f() { - // C<A> c; - // c.y.x; c.z.x; - // } + + // template<class T> class A { + // int x; + // }; + // template<class T> class A<T*> { + // char x; + // }; + // template<template<class U> class V> class C { + // V<int> y; + // V<int*> z; + // }; + // void f() { + // C<A> c; + // c.y.x; c.z.x; + // } public void testTemplateTemplateParameter() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPField x1 = (ICPPField) col.getName(2).resolveBinding(); ICPPClassTemplatePartialSpecialization A2 = (ICPPClassTemplatePartialSpecialization) col.getName(4).resolveBinding(); ICPPField x2 = (ICPPField) col.getName(7).resolveBinding(); - + ICPPClassTemplate C = (ICPPClassTemplate) col.getName(10).resolveBinding(); ICPPField y = (ICPPField) col.getName(13).resolveBinding(); ICPPField z = (ICPPField) col.getName(16).resolveBinding(); - + ICPPClassType C1 = (ICPPClassType) col.getName(18).resolveBinding(); assertTrue(C1 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)C1).getTemplateDefinition(), C); - + ICPPField y2 = (ICPPField) col.getName(23).resolveBinding(); assertTrue(y2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)y2).getSpecializedBinding(), y); + assertSame(((ICPPSpecialization) y2).getSpecializedBinding(), y); IType t = y2.getType(); assertTrue(t instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)t).getTemplateDefinition(), A1); + assertSame(((ICPPTemplateInstance) t).getTemplateDefinition(), A1); ICPPField x3 = (ICPPField) col.getName(24).resolveBinding(); assertTrue(x3 instanceof ICPPSpecialization); - assertEquals(((ICPPSpecialization)x3).getSpecializedBinding(), x1); - + assertEquals(((ICPPSpecialization) x3).getSpecializedBinding(), x1); + ICPPField z2 = (ICPPField) col.getName(26).resolveBinding(); assertTrue(z2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)z2).getSpecializedBinding(), z); + assertSame(((ICPPSpecialization) z2).getSpecializedBinding(), z); t = z2.getType(); assertTrue(t instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)t).getTemplateDefinition(), A2); + assertSame(((ICPPTemplateInstance) t).getTemplateDefinition(), A2); ICPPField x4 = (ICPPField) col.getName(27).resolveBinding(); assertTrue(x4 instanceof ICPPSpecialization); - assertEquals(((ICPPSpecialization)x4).getSpecializedBinding(), x2); - } - - // template <class T> class A { - // typedef T _T; - // _T t; - // }; - // void f() { - // A<int> a; - // a.t; - // } + assertEquals(((ICPPSpecialization) x4).getSpecializedBinding(), x2); + } + + // template <class T> class A { + // typedef T _T; + // _T t; + // }; + // void f() { + // A<int> a; + // a.t; + // } public void testNestedTypeSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ITypedef _T = (ITypedef) col.getName(3).resolveBinding(); assertSame(_T.getType(), T); - + ICPPField t = (ICPPField) col.getName(5).resolveBinding(); assertSame(t.getType(), _T); - + ICPPField t2 = (ICPPField) col.getName(11).resolveBinding(); assertTrue(t2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)t2).getSpecializedBinding(), t); - + assertSame(((ICPPSpecialization) t2).getSpecializedBinding(), t); + IType type = t2.getType(); assertTrue(type instanceof ITypedef); assertTrue(type instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)type).getSpecializedBinding(), _T); - - type = ((ITypedef)type).getType(); + assertSame(((ICPPSpecialization) type).getSpecializedBinding(), _T); + + type = ((ITypedef) type).getType(); assertTrue(type instanceof IBasicType); - assertEquals(((IBasicType)type).getType(), IBasicType.t_int); - } - - // template <class T> class A { - // class B { T t; }; - // B b; - // }; - // void f() { - // A<int> a; - // a.b.t; - // } + assertEquals(((IBasicType) type).getType(), IBasicType.t_int); + } + + // template <class T> class A { + // class B { T t; }; + // B b; + // }; + // void f() { + // A<int> a; + // a.b.t; + // } public void testNestedClassTypeSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding(); ICPPField t = (ICPPField) col.getName(4).resolveBinding(); assertSame(t.getType(), T); ICPPField b = (ICPPField) col.getName(6).resolveBinding(); assertSame(b.getType(), B); - + ICPPField b2 = (ICPPField) col.getName(12).resolveBinding(); ICPPField t2 = (ICPPField) col.getName(13).resolveBinding(); - + assertTrue(b2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)b2).getSpecializedBinding(), b); - + assertSame(((ICPPSpecialization) b2).getSpecializedBinding(), b); + IType type = b2.getType(); assertTrue(type instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)type).getSpecializedBinding(), B); - + assertSame(((ICPPSpecialization) type).getSpecializedBinding(), B); + assertTrue(t2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)t2).getSpecializedBinding(), t); + assertSame(((ICPPSpecialization) t2).getSpecializedBinding(), t); assertTrue(t2.getType() instanceof IBasicType); - assertEquals(((IBasicType)t2.getType()).getType(), IBasicType.t_int); - } - - // template <class T> class A { - // typedef typename T::X _xx; - // _xx s; - // }; - // class B {}; - // template < class T > class C { - // typedef T X; - // }; - // void f() { - // A< C<B> > a; a.s; - // }; + assertEquals(((IBasicType) t2.getType()).getType(), IBasicType.t_int); + } + + // template <class T> class A { + // typedef typename T::X _xx; + // _xx s; + // }; + // class B {}; + // template < class T > class C { + // typedef T X; + // }; + // void f() { + // A< C<B> > a; a.s; + // }; public void testTemplateParameterQualifiedType_1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateTypeParameter T = (ICPPTemplateTypeParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); - + IBinding T1 = col.getName(3).resolveBinding(); assertSame(T1, T); - + ICPPClassType X = (ICPPClassType) col.getName(4).resolveBinding(); - + ITypedef _xx = (ITypedef) col.getName(5).resolveBinding(); - + IBinding _xx2 = col.getName(6).resolveBinding(); assertSame(_xx, _xx2); assertSame(_xx.getType(), X); - + ICPPField s = (ICPPField) col.getName(7).resolveBinding(); - + ICPPClassType B = (ICPPClassType) col.getName(8).resolveBinding(); ITypedef X2 = (ITypedef) col.getName(12).resolveBinding(); - + ICPPClassType Acb = (ICPPClassType) col.getName(14).resolveBinding(); assertTrue(Acb instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)Acb).getTemplateDefinition(), A); - + ICPPField s2 = (ICPPField) col.getName(21).resolveBinding(); assertTrue(s2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)s2).getSpecializedBinding(), s); - + assertSame(((ICPPSpecialization) s2).getSpecializedBinding(), s); + IType t = s2.getType(); // assertTrue(t instanceof ITypedef); // assertTrue(t instanceof ICPPSpecialization); - // assertSame(((ICPPSpecialization)t).getSpecializedBinding(), _xx); - - t = ((ITypedef)t).getType(); + // assertSame(((ICPPSpecialization) t).getSpecializedBinding(), _xx); + + t = ((ITypedef) t).getType(); assertTrue(t instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)t).getSpecializedBinding(), X2); - - t = ((ITypedef)t).getType(); + assertSame(((ICPPSpecialization) t).getSpecializedBinding(), X2); + + t = ((ITypedef) t).getType(); assertSame(t, B); } - - // template <class T> class A { - // A<T> a; - // void f(); - // }; - // template <class U> void A<U>::f(){ - // U u; - // } + + // template <class T> class A { + // A<T> a; + // void f(); + // }; + // template <class U> void A<U>::f(){ + // U u; + // } public void testTemplateScopes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); - + ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(7).resolveBinding(); assertSame(U, T); ICPPClassType A3 = (ICPPClassType) col.getName(9).resolveBinding(); assertSame(A, A3); - - + + ICPPTemplateParameter U2 = (ICPPTemplateParameter) col.getName(13).resolveBinding(); assertSame(U, U2); assertSame(T, U); } - - // class A { - // template < class T > void f(T); - // }; - // template <class U> void A::f<>(U){} + + // class A { + // template < class T > void f(T); + // }; + // template <class U> void A::f<>(U){} public void testTemplateScopes_2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding(); ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(1).resolveBinding(); ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(2).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); assertSame(T, T2); - + ICPPTemplateParameter U = (ICPPTemplateParameter) col.getName(5).resolveBinding(); assertSame(T, U); ICPPClassType A2 = (ICPPClassType) col.getName(7).resolveBinding(); @@ -1303,15 +1303,15 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPMethod f2 = (ICPPMethod) col.getName(8).resolveBinding(); IBinding U2 = col.getName(10).resolveBinding(); assertSame(U, U2); - + assertSame(f1, f2); } - + // template<typename T> // class A {}; // // class B {}; - // + // // template<> // class A<B> {}; // @@ -1321,29 +1321,29 @@ public class AST2TemplateTests extends AST2BaseTest { // A<C> ac; public void testEnclosingScopes_a() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPSpecialization b0= ba.assertNonProblem("A<B>", 4, ICPPSpecialization.class, ICPPClassType.class); ICPPTemplateInstance b1= ba.assertNonProblem("A<C>", 4, ICPPTemplateInstance.class, ICPPClassType.class); - + ICPPClassType sc0= assertInstance(b0.getSpecializedBinding(), ICPPClassType.class); ICPPClassType sc1= assertInstance(b1.getSpecializedBinding(), ICPPClassType.class); assertTrue(sc0.isSameType(sc1)); - + assertInstance(b0, ICPPSpecialization.class); assertInstance(b1, ICPPTemplateInstance.class); - + assertInstance(b0.getScope(), ICPPTemplateScope.class); - + IScope ts0= ((ICPPClassType) b0.getSpecializedBinding()).getScope(); IScope ts1= ((ICPPClassType) b1.getSpecializedBinding()).getScope(); - + assertInstance(ts0, ICPPTemplateScope.class); - + assertSame(ts0, ts1); assertNotSame(ts0, b0.getScope()); assertSame(ts1, b1.getScope()); // a class instance exists in the same scope as the template its defined from } - + // template<typename T> // class A { // public: @@ -1364,23 +1364,23 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testEnclosingScopes_b() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPClassType b0= ba.assertNonProblem("B acb", 1, ICPPClassType.class); ICPPClassType b1= ba.assertNonProblem("B adb", 1, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType b2= ba.assertNonProblem("A<C>", 4, ICPPClassType.class, ICPPSpecialization.class); ICPPClassType b3= ba.assertNonProblem("A {", 1, ICPPClassType.class, ICPPTemplateDefinition.class); ICPPClassType b4= ba.assertNonProblem("B {}", 1, ICPPClassType.class); - + assertFalse(b0 instanceof ICPPSpecialization); - + assertSame(b0.getScope(), b2.getCompositeScope()); ICPPClassScope cs1= assertInstance(b1.getScope(), ICPPClassScope.class); assertInstance(cs1.getClassType(), ICPPTemplateInstance.class); assertSame(b4.getScope(), b3.getCompositeScope()); } - + // class A {}; - // + // // template<typename T> // class X { // public: @@ -1393,17 +1393,17 @@ public class AST2TemplateTests extends AST2BaseTest { // X<A>::Y::Z xayz; public void testEnclosingScopes_c() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPClassType b0= ba.assertNonProblem("Y::Z x", 1, ICPPClassType.class); ICPPClassType b1= ba.assertNonProblem("Z xayz", 1, ICPPClassType.class); - + ICPPClassScope cs0= assertInstance(b0.getScope(), ICPPClassScope.class); assertInstance(cs0.getClassType(), ICPPSpecialization.class); - + ICPPClassScope cs1= assertInstance(b1.getScope(), ICPPClassScope.class); - assertInstance(cs1.getClassType(), ICPPSpecialization.class); + assertInstance(cs1.getClassType(), ICPPSpecialization.class); } - + // class A {}; class B {}; // // template<typename T1, typename T2> @@ -1418,421 +1418,421 @@ public class AST2TemplateTests extends AST2BaseTest { // X<B,A>::N n; public void testEnclosingScopes_d() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPClassType b0= ba.assertNonProblem("N n", 1, ICPPClassType.class); ICPPClassType b1= ba.assertNonProblem("N {", 1, ICPPClassType.class); - + ICPPClassScope s0= assertInstance(b0.getScope(), ICPPClassScope.class); assertInstance(s0.getClassType(), ICPPTemplateInstance.class); - + ICPPClassScope s1= assertInstance(b1.getScope(), ICPPClassScope.class); assertInstance(s1.getClassType(), ICPPTemplateDefinition.class); - + ICPPTemplateScope s2= assertInstance(s1.getClassType().getScope(), ICPPTemplateScope.class); } - - // template<class T> struct A { - // void f(T); - // template<class X> void g(T,X); - // void h(T) { } - // }; - // template<> void A<int>::f(int); - // template<class T> template<class X> void A<T>::g(T,X) { } - // template<> template<class X> void A<int>::g(int,X); - // template<> template<> void A<int>::g(int,char); - // template<> template<> void A<int>::g<char>(int,char); - // template<> void A<int>::h(int) { } + + // template<class T> struct A { + // void f(T); + // template<class X> void g(T,X); + // void h(T) { } + // }; + // template<> void A<int>::f(int); + // template<class T> template<class X> void A<T>::g(T,X) { } + // template<> template<class X> void A<int>::g(int,X); + // template<> template<> void A<int>::g(int,char); + // template<> template<> void A<int>::g<char>(int,char); + // template<> void A<int>::h(int) { } public void test14_7_3s16() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassType A = (ICPPClassType) col.getName(1).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(2).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); assertSame(T, T2); - + ICPPTemplateParameter X = (ICPPTemplateParameter) col.getName(5).resolveBinding(); ICPPFunctionTemplate g = (ICPPFunctionTemplate) col.getName(6).resolveBinding(); ICPPTemplateParameter T3 = (ICPPTemplateParameter) col.getName(7).resolveBinding(); assertSame(T, T3); ICPPTemplateParameter X2 = (ICPPTemplateParameter) col.getName(9).resolveBinding(); assertSame(X, X2); - + ICPPMethod h = (ICPPMethod) col.getName(11).resolveBinding(); ICPPTemplateParameter T4 = (ICPPTemplateParameter) col.getName(12).resolveBinding(); assertSame(T, T4); - + ICPPClassType A2 = (ICPPClassType) col.getName(15).resolveBinding(); assertTrue(A2 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A); ICPPMethod f2 = (ICPPMethod) col.getName(17).resolveBinding(); assertTrue(f2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)f2).getSpecializedBinding(), f); - + assertSame(((ICPPSpecialization) f2).getSpecializedBinding(), f); + ICPPTemplateParameter TR = (ICPPTemplateParameter) col.getName(19).resolveBinding(); assertSame(T, TR); ICPPTemplateParameter XR = (ICPPTemplateParameter) col.getName(20).resolveBinding(); assertSame(X, XR); ICPPClassType A3 = (ICPPClassType) col.getName(22).resolveBinding(); assertSame(A3, A); - + ICPPMethod g2 = (ICPPMethod) col.getName(25).resolveBinding(); assertSame(g2, g); TR = (ICPPTemplateParameter) col.getName(26).resolveBinding(); assertSame(T, TR); XR = (ICPPTemplateParameter) col.getName(28).resolveBinding(); assertSame(X, XR); - + assertSame(col.getName(32).resolveBinding(), A2); assertSame(col.getName(39).resolveBinding(), A2); assertSame(col.getName(45).resolveBinding(), A2); assertSame(col.getName(52).resolveBinding(), A2); - + ICPPMethod h2 = (ICPPMethod) col.getName(54).resolveBinding(); assertTrue(h2 instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)h2).getSpecializedBinding(), h); - } - - // namespace N { - // int C; - // template<class T> class B { - // void f(T); - // }; - // } - // template<class C> void N::B<C>::f(C) { - // C b; // C is the template parameter, not N::C - // } + assertSame(((ICPPSpecialization) h2).getSpecializedBinding(), h); + } + + // namespace N { + // int C; + // template<class T> class B { + // void f(T); + // }; + // } + // template<class C> void N::B<C>::f(C) { + // C b; // C is the template parameter, not N::C + // } public void test14_6_1s6() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(2).resolveBinding(); ICPPClassTemplate B = (ICPPClassTemplate) col.getName(3).resolveBinding(); ICPPMethod f = (ICPPMethod) col.getName(4).resolveBinding(); ICPPTemplateParameter TR = (ICPPTemplateParameter) col.getName(5).resolveBinding(); assertSame(T, TR); - + ICPPTemplateParameter C = (ICPPTemplateParameter) col.getName(7).resolveBinding(); assertSame(C, T); - + ICPPClassType B2 = (ICPPClassType) col.getName(10).resolveBinding(); assertSame(B2, B); - + ICPPTemplateParameter CR = (ICPPTemplateParameter) col.getName(12).resolveBinding(); assertSame(CR, T); - + ICPPMethod f2 = (ICPPMethod) col.getName(13).resolveBinding(); assertSame(f2, f); - + CR = (ICPPTemplateParameter) col.getName(14).resolveBinding(); assertSame(CR, T); CR = (ICPPTemplateParameter) col.getName(16).resolveBinding(); assertSame(CR, T); } - - // template <class T> class Array {}; - // template <class T> void sort(Array<T> &); - // template void sort<>(Array<int> &); + + // template <class T> class Array {}; + // template <class T> void sort(Array<T> &); + // template void sort<>(Array<int> &); public void testBug90689_ExplicitInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPFunctionTemplate s = (ICPPFunctionTemplate) col.getName(3).resolveBinding(); - + ICPPClassType A2 = (ICPPClassType) col.getName(4).resolveBinding(); assertTrue(A2 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A); - + ICPPFunction s2 = (ICPPFunction) col.getName(8).resolveBinding(); assertTrue(s2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)s2).getTemplateDefinition(), s); - + assertSame(((ICPPTemplateInstance) s2).getTemplateDefinition(), s); + ICPPClassType A3 = (ICPPClassType) col.getName(10).resolveBinding(); assertTrue(A3 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A3).getTemplateDefinition(), A); assertNotSame(A2, A3); } - - // template<class T> class Array { }; - // template class Array<char>; - // template<class T> void sort(Array<T>& v) { } - // template void sort(Array<char>&); // argument is deduced here + + // template<class T> class Array { }; + // template class Array<char>; + // template<class T> void sort(Array<T>& v) { } + // template void sort(Array<char>&); // argument is deduced here public void test14_7_2s2_ExplicitInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A1 = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType A2 = (ICPPClassType) col.getName(2).resolveBinding(); assertTrue(A2 instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A2).getTemplateDefinition(), A1); - + ICPPFunctionTemplate s1 = (ICPPFunctionTemplate) col.getName(5).resolveBinding(); ICPPFunction s2 = (ICPPFunction) col.getName(10).resolveBinding(); assertTrue(s2 instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)s2).getTemplateDefinition(), s1); - + assertSame(((ICPPTemplateInstance) s2).getTemplateDefinition(), s1); + ICPPClassType A3 = (ICPPClassType) col.getName(11).resolveBinding(); assertSame(A2, A3); } - - // template <class T> class A { - // A<T>* p; - // void f() { this; } - // }; + + // template <class T> class A { + // A<T>* p; + // void f() { this; } + // }; public void testBug74204() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + IField p = (IField) col.getName(5).resolveBinding(); - + IASTName f = col.getName(6); IASTFunctionDefinition fdef = (IASTFunctionDefinition) f.getParent().getParent(); - IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement)fdef.getBody()).getStatements()[0]; + IASTExpressionStatement statement = (IASTExpressionStatement) ((IASTCompoundStatement) fdef.getBody()).getStatements()[0]; IType type = statement.getExpression().getExpressionType(); - + assertTrue(type.isSameType(p.getType())); } - - // template <class T > void f(T); - // template <class T > void g(T t){ - // f(t); - // } + + // template <class T > void f(T); + // template <class T > void g(T t){ + // f(t); + // } public void testDeferredFunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(8).resolveBinding(); assertTrue(f2 instanceof ICPPUnknownBinding); } - - // template < class T > class A {}; - // template < class T > class B { - // void init(A<T> *); - // }; - // template < class T > class C : public B<T> { - // C(A<T> * a) { - // init(a); - // } - // }; + + // template < class T > class A {}; + // template < class T > class B { + // void init(A<T> *); + // }; + // template < class T > class C : public B<T> { + // C(A<T> * a) { + // init(a); + // } + // }; public void testRelaxationForTemplateInheritance() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPMethod init = (ICPPMethod) col.getName(4).resolveBinding(); // the instantiation of B<T> has to be deferred, therefore 'init' is an unknown binding. assertInstance(col.getName(19).resolveBinding(), ICPPUnknownBinding.class); } - - // template <class Tp, class Tr > class iter { - // Tp operator -> () const; - // Tr operator [] (int) const; - // }; - // template <class T> class list { - // typedef iter< T*, T& > iterator; - // iterator begin(); - // iterator end(); - // }; - // class Bar { public: int foo; }; - // void f() { - // list<Bar> bar; - // for(list<Bar>::iterator i = bar.begin(); i != bar.end(); ++i){ - // i->foo; i[0].foo; - // } - // } + + // template <class Tp, class Tr > class iter { + // Tp operator -> () const; + // Tr operator [] (int) const; + // }; + // template <class T> class list { + // typedef iter< T*, T& > iterator; + // iterator begin(); + // iterator end(); + // }; + // class Bar { public: int foo; }; + // void f() { + // list<Bar> bar; + // for(list<Bar>::iterator i = bar.begin(); i != bar.end(); ++i){ + // i->foo; i[0].foo; + // } + // } public void testBug91707() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPMethod begin = (ICPPMethod) col.getName(16).resolveBinding(); ICPPMethod end = (ICPPMethod) col.getName(18).resolveBinding(); - + ICPPField foo = (ICPPField) col.getName(20).resolveBinding(); - + IBinding r = col.getName(33).resolveBinding(); assertTrue(r instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)r).getSpecializedBinding(), begin); - + assertSame(((ICPPSpecialization) r).getSpecializedBinding(), begin); + r = col.getName(36).resolveBinding(); assertTrue(r instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)r).getSpecializedBinding(), end); - + assertSame(((ICPPSpecialization) r).getSpecializedBinding(), end); + assertSame(foo, col.getName(39).resolveBinding()); assertSame(foo, col.getName(41).resolveBinding()); } - - // class B { int i; }; - // template <class T > class A { - // typedef T* _T; - // }; - // void f(){ - // A<B>::_T t; - // (*t).i; - // } + + // class B { int i; }; + // template <class T > class A { + // typedef T* _T; + // }; + // void f(){ + // A<B>::_T t; + // (*t).i; + // } public void testBug98961() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassType B = (ICPPClassType) col.getName(0).resolveBinding(); ICPPField i = (ICPPField) col.getName(1).resolveBinding(); ITypedef _T = (ITypedef) col.getName(5).resolveBinding(); ICPPVariable t = (ICPPVariable) col.getName(12).resolveBinding(); - + IType type = t.getType(); assertTrue(type instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)type).getSpecializedBinding(), _T); - assertSame(((IPointerType)((ITypedef)type).getType()).getType(), B); + assertSame(((ICPPSpecialization) type).getSpecializedBinding(), _T); + assertSame(((IPointerType) ((ITypedef) type).getType()).getType(), B); assertSame(i, col.getName(14).resolveBinding()); } - - // class A { - // template <class T > void f(T) { - // begin(); - // } - // void begin(); - // }; + + // class A { + // template <class T > void f(T) { + // begin(); + // } + // void begin(); + // }; public void testBug98784() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertSame(col.getName(5).resolveBinding(), col.getName(6).resolveBinding()); } - - // template <class T> class A { - // A(T t); - // }; - // void f(A<int> a); - // void m(){ - // f(A<int>(1)); - // } + + // template <class T> class A { + // A(T t); + // }; + // void f(A<int> a); + // void m(){ + // f(A<int>(1)); + // } public void testBug99254() throws Exception{ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPConstructor ctor = (ICPPConstructor) col.getName(2).resolveBinding(); ICPPFunction f = (ICPPFunction) col.getName(5).resolveBinding(); - + final IASTName typeConversion = col.getName(11); ICPPSpecialization spec = (ICPPSpecialization) typeConversion.resolveBinding(); assertSame(ctor.getOwner(), spec.getSpecializedBinding()); - + final ICPPASTFunctionCallExpression fcall = (ICPPASTFunctionCallExpression) typeConversion.getParent().getParent(); final IBinding ctorSpec = fcall.getImplicitNames()[0].resolveBinding(); assertSame(ctor, (((ICPPSpecialization) ctorSpec).getSpecializedBinding())); - + assertSame(f, col.getName(10).resolveBinding()); } - - // namespace core { - // template<class T> class A { - // A(T x, T y); - // }; - // } - // class B { - // int add(const core::A<int> &rect); - // }; - // void f(B* b){ - // b->add(core::A<int>(10, 2)); - // } + + // namespace core { + // template<class T> class A { + // A(T x, T y); + // }; + // } + // class B { + // int add(const core::A<int> &rect); + // }; + // void f(B* b){ + // b->add(core::A<int>(10, 2)); + // } public void testBug99254_2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPConstructor ctor = (ICPPConstructor) col.getName(3).resolveBinding(); ICPPMethod add = (ICPPMethod) col.getName(9).resolveBinding(); - + final IASTName typeConversion = col.getName(20); ICPPSpecialization spec = (ICPPSpecialization) typeConversion.resolveBinding(); assertSame(ctor.getOwner(), spec.getSpecializedBinding()); - + final ICPPASTFunctionCallExpression fcall = (ICPPASTFunctionCallExpression) typeConversion.getParent().getParent(); final IBinding ctorSpec = fcall.getImplicitNames()[0].resolveBinding(); assertSame(ctor, (((ICPPSpecialization) ctorSpec).getSpecializedBinding())); assertSame(add, col.getName(19).resolveBinding()); } - - // template <class T> class A { A(T); }; - // typedef signed int s32; - // class B { - // int add(const A<s32> &rect); - // }; - // void f(B* b){ - // b->add(A<int>(10)); - // } + + // template <class T> class A { A(T); }; + // typedef signed int s32; + // class B { + // int add(const A<s32> &rect); + // }; + // void f(B* b){ + // b->add(A<int>(10)); + // } public void testBug99254_3() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPConstructor ctor = (ICPPConstructor) col.getName(2).resolveBinding(); ICPPMethod add = (ICPPMethod) col.getName(7).resolveBinding(); - + final IASTName typeConversion = col.getName(17); ICPPSpecialization spec = (ICPPSpecialization) typeConversion.resolveBinding(); assertSame(ctor.getOwner(), spec.getSpecializedBinding()); - + final ICPPASTFunctionCallExpression fcall = (ICPPASTFunctionCallExpression) typeConversion.getParent().getParent(); final IBinding ctorSpec = fcall.getImplicitNames()[0].resolveBinding(); assertSame(ctor, (((ICPPSpecialization) ctorSpec).getSpecializedBinding())); assertSame(add, col.getName(16).resolveBinding()); } - + public void testBug98666() throws Exception { CPPASTNameBase.sAllowNameComputation= true; IASTTranslationUnit tu = parse("A::template B<T> b;", ParserLanguage.CPP); //$NON-NLS-1$ CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPASTQualifiedName qn = (ICPPASTQualifiedName) col.getName(0); IASTName[] ns = qn.getNames(); assertTrue(ns[1] instanceof ICPPASTTemplateId); assertEquals(ns[1].toString(), "B<T>"); //$NON-NLS-1$ } - - // template <class T> struct A{ - // class C { - // template <class T2> struct B {}; - // }; - // }; - // template <class T> template <class T2> - // struct A<T>::C::B<T2*>{}; - // A<short>::C::B<int*> ab; + + // template <class T> struct A{ + // class C { + // template <class T2> struct B {}; + // }; + // }; + // template <class T> template <class T2> + // struct A<T>::C::B<T2*>{}; + // A<short>::C::B<int*> ab; public void testBug90678() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPTemplateParameter T2 = (ICPPTemplateParameter) col.getName(3).resolveBinding(); - + ICPPClassTemplate B = (ICPPClassTemplate) col.getName(4).resolveBinding(); - + assertSame(T, col.getName(5).resolveBinding()); final IBinding T2ofPartialSpec = col.getName(6).resolveBinding(); assertNotSame(T2, T2ofPartialSpec); // partial spec has its own template params assertSame(T, col.getName(10).resolveBinding()); assertSame(T2ofPartialSpec, col.getName(14).resolveBinding()); - + ICPPClassTemplatePartialSpecialization spec = (ICPPClassTemplatePartialSpecialization) col.getName(12).resolveBinding(); assertSame(spec.getPrimaryClassTemplate(), B); - + ICPPClassType BI = (ICPPClassType) col.getName(19).resolveBinding(); assertTrue(BI instanceof ICPPTemplateInstance); final IBinding partialSpecSpec = ((ICPPTemplateInstance)BI).getSpecializedBinding(); @@ -1840,7 +1840,7 @@ public class AST2TemplateTests extends AST2BaseTest { IBinding partialSpec= ((ICPPSpecialization) partialSpecSpec).getSpecializedBinding(); assertSame(partialSpec, spec); } - + // template <class T> int f(T); // #1 // int f(int); // #2 // int k = f(1); // uses #2 @@ -1850,181 +1850,181 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse(content, ParserLanguage.CPP); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); ICPPFunction f2 = (ICPPFunction) col.getName(4).resolveBinding(); - + assertSame(f2, col.getName(7).resolveBinding()); - + IBinding b = col.getName(9).resolveBinding(); // resolve the binding of the ICPPASTTemplateId first assertTrue(b instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)b).getSpecializedBinding(), f1); + assertSame(((ICPPTemplateInstance) b).getSpecializedBinding(), f1); assertSame(f1, col.getName(10).resolveBinding()); - - + + tu = parse(content,ParserLanguage.CPP); col = new CPPNameCollector(); tu.accept(col); - + f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding(); assertSame(f1, col.getName(10).resolveBinding()); } - - // template <class T, int someConst = 0 > class A {}; - // int f() { - // const int local = 10; - // A<int, local> broken; - // }; + + // template <class T, int someConst = 0 > class A {}; + // int f() { + // const int local = 10; + // A<int, local> broken; + // }; public void testBug103578() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate A = (ICPPClassTemplate) col.getName(2).resolveBinding(); IVariable local = (IVariable) col.getName(4).resolveBinding(); - + ICPPClassType a = (ICPPClassType) col.getName(5).resolveBinding(); assertTrue(a instanceof ICPPTemplateInstance); - assertSame(((ICPPTemplateInstance)a).getTemplateDefinition(), A); + assertSame(((ICPPTemplateInstance) a).getTemplateDefinition(), A); assertSame(local, col.getName(7).resolveBinding()); } - - // template <class T> class A : public T {}; - // class B { int base; }; - // void f() { - // A< B > a; - // a.base; - // } + + // template <class T> class A : public T {}; + // class B { int base; }; + // void f() { + // A< B > a; + // a.base; + // } public void testBug103715() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPField base = (ICPPField) col.getName(4).resolveBinding(); assertSame(base, col.getName(11).resolveBinding()); - + ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding(); ICPPClassType A = (ICPPClassType) col.getName(6).resolveBinding(); - + ICPPBase[] bases = A.getBases(); assertEquals(bases.length, 1); assertSame(bases[0].getBaseClass(), B); } - - // template < class T > class complex; - // template <> class complex <float>; - // template < class T > class complex{ - // }; - // template <> class complex< float > { - // void f(float); - // }; - // void complex<float>::f(float){ - // } + + // template < class T > class complex; + // template <> class complex <float>; + // template < class T > class complex{ + // }; + // template <> class complex< float > { + // void f(float); + // }; + // void complex<float>::f(float){ + // } public void testBug74276() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPClassTemplate complex = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPClassType cspec = (ICPPClassType) col.getName(2).resolveBinding(); assertTrue(cspec instanceof ICPPSpecialization); - assertSame(((ICPPSpecialization)cspec).getSpecializedBinding(), complex); - + assertSame(((ICPPSpecialization) cspec).getSpecializedBinding(), complex); + assertSame(complex, col.getName(5).resolveBinding()); assertSame(cspec, col.getName(6).resolveBinding()); - + ICPPMethod f = (ICPPMethod) col.getName(8).resolveBinding(); assertSame(f, col.getName(10).resolveBinding()); } - - // template< class T1, int q > class C {}; - // template< class T1, class T2> class A {}; + + // template< class T1, int q > class C {}; + // template< class T1, class T2> class A {}; // template< class T1, class T2, int q1, int q2> - // class A< C<T1, q1>, C<T2, q2> > {}; - // class N {}; - // typedef A<C<N,1>, C<N,1> > myType; - // void m(){ - // myType t; - // } + // class A< C<T1, q1>, C<T2, q2> > {}; + // class N {}; + // typedef A<C<N,1>, C<N,1> > myType; + // void m(){ + // myType t; + // } public void testBug105852() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ITypedef myType = (ITypedef) col.getName(31).resolveBinding(); ICPPClassType A = (ICPPClassType) myType.getType(); - + ICPPSpecialization Aspec = (ICPPSpecialization) col.getName(10).resolveBinding(); - + assertTrue(A instanceof ICPPTemplateInstance); assertSame(((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec); } - - // template< class T > class A : public T {}; - // class C { public: int c; }; - // class B : public A<C> { }; - // void main(){ - // B k; - // k.c; - // } + + // template< class T > class A : public T {}; + // class C { public: int c; }; + // class B : public A<C> { }; + // void main(){ + // B k; + // k.c; + // } public void testBug105769() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPVariable c = (ICPPVariable) col.getName(13).resolveBinding(); assertSame(c, col.getName(4).resolveBinding()); } - - // template< class T > class C { - // public: void * blah; - // template<typename G> C(G* g) : blah(g) {} - // template <> C(char * c) : blah(c) {} - // template <> C(wchar_t * c) : blah(c) {} - // }; + + // template< class T > class C { + // public: void * blah; + // template<typename G> C(G* g) : blah(g) {} + // template <> C(char * c) : blah(c) {} + // template <> C(wchar_t * c) : blah(c) {} + // }; public void testBug162230() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPTemplateParameter T = (ICPPTemplateParameter) col.getName(0).resolveBinding(); ICPPClassTemplate C = (ICPPClassTemplate) col.getName(1).resolveBinding(); ICPPField blah = (ICPPField) col.getName(2).resolveBinding(); ICPPTemplateTypeParameter G = (ICPPTemplateTypeParameter) col.getName(3).resolveBinding(); ICPPFunctionTemplate ctor = (ICPPFunctionTemplate) col.getName(4).resolveBinding(); - + assertSame(G, col.getName(5).resolveBinding()); ICPPParameter g = (ICPPParameter) col.getName(6).resolveBinding(); assertSame(blah, col.getName(7).resolveBinding()); assertSame(g, col.getName(8).resolveBinding()); - + ICPPSpecialization spec = (ICPPSpecialization) col.getName(9).resolveBinding(); assertSame(spec.getSpecializedBinding(), ctor); - + ICPPParameter c = (ICPPParameter) col.getName(10).resolveBinding(); - + assertSame(blah, col.getName(11).resolveBinding()); assertSame(c, col.getName(12).resolveBinding()); - + ICPPSpecialization spec2 = (ICPPSpecialization) col.getName(13).resolveBinding(); assertSame(spec.getSpecializedBinding(), ctor); - + ICPPParameter c2 = (ICPPParameter) col.getName(14).resolveBinding(); - + assertSame(blah, col.getName(15).resolveBinding()); assertSame(c2, col.getName(16).resolveBinding()); } - - // template< class T > class C {}; - // typedef struct C<int> CInt; + + // template< class T > class C {}; + // typedef struct C<int> CInt; public void testBug169628() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertTrue(col.getName(2).resolveBinding() instanceof ICPPSpecialization); } - + // template<class T1> // struct Closure { // Closure(T1* obj1, void (T1::*method1)()) {} @@ -2086,7 +2086,7 @@ public class AST2TemplateTests extends AST2BaseTest { // // template <class _C> // typename _C::value_type GetPair(_C& collection, typename _C::value_type::first_type key); - // + // // int main(map<int, int> x) { // GetPair(x, 1); // } @@ -2146,22 +2146,22 @@ public class AST2TemplateTests extends AST2BaseTest { // const A a= *new A(); // const C<const A> ca= *new C<const A>(*new A()); // - // foo(a); + // foo(a); // bar(ca); // } public void testBug214646() throws Exception { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); - + IBinding b0= bh.assertNonProblem("foo(a)", 3); IBinding b1= bh.assertNonProblem("bar(ca)", 3); - + assertInstance(b0, ICPPFunction.class); assertInstance(b1, ICPPFunction.class); - + ICPPFunction f0= (ICPPFunction) b0, f1= (ICPPFunction) b1; assertEquals(1, f0.getParameters().length); assertEquals(1, f1.getParameters().length); - + assertInstance(f0.getParameters()[0].getType(), ICPPClassType.class); assertFalse(f0 instanceof ICPPTemplateInstance); assertFalse(f0 instanceof ICPPTemplateDefinition); @@ -2188,7 +2188,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPFunction b1= bh.assertNonProblem("func(a2)", 4, ICPPFunction.class); assertSame(b0, b1); } - + // struct A {}; // // template <class T1> @@ -2211,7 +2211,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPFunction b1= bh.assertNonProblem("func(a2)", 4, ICPPFunction.class); assertNotSame(b0, b1); } - + // namespace ns { // // template<class _M1, class _M2> @@ -2278,7 +2278,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testFunctionTemplate_272848_1() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); } // template <typename S> @@ -2295,7 +2295,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testFunctionTemplate_272848_2() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); } // template<typename T, typename U> @@ -2309,7 +2309,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testFunctionTemplate_309564() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); } // template<class U> void f1(void(*f)(const U&)) {} @@ -2319,7 +2319,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testSimplifiedFunctionTemplateWithFunctionPointer_281783() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); } // template <class T> @@ -2363,38 +2363,38 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testCPPConstructorTemplateSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); - + CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + ICPPASTTemplateId tid= (ICPPASTTemplateId) col.getName(20); IASTName cn= col.getName(21); assertInstance(cn.resolveBinding(), ICPPClassTemplate.class); // *D*<int>(5, 6) assertInstance(cn.resolveBinding(), ICPPClassType.class); // *D*<int>(5, 6) assertInstance(tid.resolveBinding(), ICPPTemplateInstance.class); // *D<int>*(5, 6) assertInstance(tid.resolveBinding(), ICPPConstructor.class); // *D<int>*(5, 6) - - IBinding tidSpc= ((ICPPTemplateInstance)tid.resolveBinding()).getSpecializedBinding(); + + IBinding tidSpc= ((ICPPTemplateInstance) tid.resolveBinding()).getSpecializedBinding(); assertInstance(tidSpc, ICPPConstructor.class); assertInstance(tidSpc, ICPPSpecialization.class); assertInstance(tidSpc, ICPPFunctionTemplate.class); } - + // template<class T> const T& (max)(const T& lhs, const T& rhs) { // return (lhs < rhs ? rhs : lhs); // } public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); - + CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + IASTName name; for (Object element : col.nameList) { name = (IASTName) element; assertFalse(name.resolveBinding() instanceof IProblemBinding); } - + name= col.nameList.get(0); assertTrue(name.resolveBinding() instanceof ICPPTemplateParameter); name= col.nameList.get(1); @@ -2418,7 +2418,7 @@ public class AST2TemplateTests extends AST2BaseTest { name= col.nameList.get(10); assertTrue(name.resolveBinding() instanceof IParameter); } - + // template<typename TpA> // class A { // public: @@ -2435,7 +2435,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateTypedef_214447() throws Exception { CPPASTNameBase.sAllowNameComputation= true; IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); - + CPPNameCollector col = new CPPNameCollector(); tu.accept(col); for (IASTName name : col.nameList) { @@ -2469,7 +2469,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testRebindPattern_214447_1() throws Exception { CPPASTNameBase.sAllowNameComputation= true; IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); - + CPPNameCollector col = new CPPNameCollector(); tu.accept(col); for (IASTName name : col.nameList) { @@ -2482,7 +2482,7 @@ public class AST2TemplateTests extends AST2BaseTest { } } } - + // template<typename _TpAllocator> // class Allocator { // public: @@ -2509,7 +2509,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testRebindPattern_214447_2() throws Exception { CPPASTNameBase.sAllowNameComputation= true; IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); - + CPPNameCollector col = new CPPNameCollector(); tu.accept(col); for (IASTName name : col.nameList) { @@ -2609,7 +2609,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDefaultTemplateParameter() throws Exception { CPPASTNameBase.sAllowNameComputation= true; IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); - + CPPNameCollector col = new CPPNameCollector(); tu.accept(col); for (IASTName name : col.nameList) { @@ -2661,7 +2661,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); ICPPFunction fn= bh.assertNonProblem("foo(d)", 3, ICPPFunction.class); } - + // class B {}; // template<typename T> // class C { @@ -2681,7 +2681,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); ICPPFunction fn= bh.assertNonProblem("foo(d)", 3, ICPPFunction.class); } - + // class Z {}; // template<typename TA> // class A { @@ -2692,7 +2692,7 @@ public class AST2TemplateTests extends AST2BaseTest { // template<typename TB> // class B : public A<TB> {}; // template<typename TC> - // class C : public B<TC> {}; + // class C : public B<TC> {}; // template<typename TD> // class D : public C<TD> {}; // template<typename TE> @@ -2704,7 +2704,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); ICPPFunction fn= bh.assertNonProblem("foo(*new", 3, ICPPFunction.class); } - + // class X {}; class B {}; // template<typename T> // class C { @@ -2728,7 +2728,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); ICPPFunction fn= bh.assertNonProblem("foo(cx", 3, ICPPFunction.class); } - + // class A; // // int foo(A a); @@ -2747,7 +2747,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ba.assertNonProblem("foo(c);", 3); } - + // template<int x> // class A {}; // @@ -2757,11 +2757,11 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(4).getParent(), ICPPASTTemplateId.class); assertInstance(col.getName(5).getParent(), IASTIdExpression.class); } - + // class X { // template<int x> // class A {}; @@ -2776,11 +2776,11 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(5).getParent(), ICPPASTTemplateId.class); assertInstance(col.getName(6).getParent(), IASTIdExpression.class); } - + // template<int x> // class A {}; // @@ -2790,12 +2790,12 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(4).getParent(), ICPPASTTemplateId.class); assertInstance(col.getName(5).getParent(), IASTIdExpression.class); assertInstance(col.getName(5).getParent().getParent(), IASTBinaryExpression.class); } - + // template<int x> // class A {}; // @@ -2805,20 +2805,20 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(3), ICPPASTTemplateId.class); - assertInstance(((ICPPASTTemplateId)col.getName(3)).getTemplateArguments()[0], ICPPASTUnaryExpression.class); + assertInstance(((ICPPASTTemplateId) col.getName(3)).getTemplateArguments()[0], ICPPASTUnaryExpression.class); } - - // template<class T1, int q> class C {}; + + // template<class T1, int q> class C {}; // template<class T1, class T2> class A {}; // template< class T1, class T2, int q1, int q2> - // class A< C<T1, q1>, C<T2, q2> > {}; + // class A< C<T1, q1>, C<T2, q2> > {}; public void testTemplateIdAsTemplateArgumentIsTypeId_229942_e() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + // 12 is template-id: C<T1, q1> assertInstance(col.getName(12), ICPPASTTemplateId.class); assertInstance(col.getName(12).getParent(), ICPPASTNamedTypeSpecifier.class); @@ -2829,7 +2829,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertInstance(col.getName(16).getParent(), ICPPASTNamedTypeSpecifier.class); assertInstance(col.getName(16).getParent().getParent(), IASTTypeId.class); } - + // template <class T> // struct A { // A(T* t) {} @@ -2847,15 +2847,15 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTypeIdAsTemplateArgumentIsTypeId_229942_f() throws Exception { BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true); ba.assertNonProblem("T> at) {", 1); - + IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(23).getParent().getParent(), IASTTypeId.class); assertInstance(col.getName(23).resolveBinding(), ICPPTemplateTypeParameter.class); } - + // template <class T> // struct A {}; // @@ -2871,15 +2871,15 @@ public class AST2TemplateTests extends AST2BaseTest { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + // 7 is T in A<T> assertInstance(col.getName(7).getParent(), ICPPASTNamedTypeSpecifier.class); assertInstance(col.getName(7).getParent().getParent(), IASTTypeId.class); - + // 17 is i in A<i> assertInstance(col.getName(17).getParent(), IASTIdExpression.class); } - + // typedef int td; // template<> class Alias<td const *> { // }; @@ -2894,7 +2894,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertEquals(1, args.length); assertInstance(args[0], IASTTypeId.class); } - + // // From discussion in 207840. See 14.3.4. // class A {}; // @@ -2907,7 +2907,7 @@ public class AST2TemplateTests extends AST2BaseTest { // B b1; // B<> b2; // error - no default args // - // C c1; + // C c1; // C<> c2; // ok - default args public void testMissingTemplateArgumentLists() throws Exception { BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true); @@ -2918,13 +2918,13 @@ public class AST2TemplateTests extends AST2BaseTest { ba.assertNonProblem("C<> c2", 1, ICPPTemplateDefinition.class, ICPPClassType.class); ba.assertNonProblem("C<> c2", 3, ICPPTemplateInstance.class, ICPPClassType.class); } - + // template<class T1, int N> class TestClass { // int member1; // void fun1(void); // }; // template<class T1,int N> inline void TestClass<T1,N>::fun1(void) { - // member1 = 0; + // member1 = 0; // } public void testDefinitionOfClassTemplateWithNonTypeParameter() throws Exception { BindingAssertionHelper ba=new BindingAssertionHelper(getAboveComment(), true); @@ -2937,18 +2937,18 @@ public class AST2TemplateTests extends AST2BaseTest { } // class Z {}; - // + // // template<typename T1> // class A { // public: // template<typename T2 = Z> class B; // }; - // + // // template<> template<typename T3> class A<short>::B { // public: // T3 foo() { return (T3) 0; } // }; - // + // // void ref() { // A<short>::B<> b; // } @@ -2973,20 +2973,20 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPClassType b2= ba.assertNonProblem("A<B, 0>", 7, ICPPClassType.class, ICPPTemplateInstance.class); ICPPClassType b3= ba.assertNonProblem("A<B, 1>", 7, ICPPClassType.class, ICPPTemplateInstance.class); ICPPClassType b4= ba.assertNonProblem("A<B, 2>", 7, ICPPClassType.class, ICPPTemplateInstance.class); - + assertTrue(!b2.isSameType(b3)); assertTrue(!b3.isSameType(b4)); assertTrue(!b4.isSameType(b2)); - + ICPPClassType X= ba.assertNonProblem("X x", 1, ICPPClassType.class); ICPPClassType Y= ba.assertNonProblem("Y y", 1, ICPPClassType.class); ICPPClassType Z= ba.assertNonProblem("Z z", 1, ICPPClassType.class); - + assertTrue(!X.isSameType(Y)); assertTrue(!Y.isSameType(Z)); assertTrue(!Z.isSameType(X)); } - + // template<class T, bool b> class A {public: class X {};}; // template<class T1> class A<T1,true> {public: class Y {};}; // @@ -2999,15 +2999,15 @@ public class AST2TemplateTests extends AST2BaseTest { // A<B, false>::Y y; //4 should be an error public void testNonTypeBooleanArgumentDisambiguation() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPClassType X= ba.assertNonProblem("X x; //1", 1, ICPPClassType.class); ICPPClassType Y= ba.assertNonProblem("Y y; //2", 1, ICPPClassType.class); ba.assertProblem("X x; //3", 1); ba.assertProblem("Y y; //4", 1); - + assertTrue(!X.isSameType(Y)); } - + // template <int x> // class C { // public: @@ -3030,37 +3030,37 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testBug207871() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPVariable _256= ba.assertNonProblem("_256=0x100", 4, ICPPVariable.class); IQualifierType qt1= assertInstance(_256.getType(), IQualifierType.class); ICPPBasicType bt1= assertInstance(qt1.getType(), ICPPBasicType.class); assertEquals(256, _256.getInitialValue().numericalValue().intValue()); - + ICPPVariable t= ba.assertNonProblem("t;", 1, ICPPVariable.class); ICPPTemplateInstance ci1= assertInstance(t.getType(), ICPPTemplateInstance.class, ICPPClassType.class); ObjectMap args1= ci1.getArgumentMap(); assertEquals(1, args1.size()); assertInstance(args1.keyAt(0), ICPPTemplateNonTypeParameter.class); - + // non-type arguments are currently modelled as a type with attached expression ICPPBasicType bt0= assertInstance(args1.getAt(0), ICPPBasicType.class); assertEquals(bt0.getType(), IBasicType.t_int); assertEquals(256, ci1.getTemplateArguments()[0].getNonTypeValue().numericalValue().intValue()); - + ICPPTemplateInstance ct= ba.assertNonProblem("C<_256> ", 7, ICPPTemplateInstance.class, ICPPClassType.class); ObjectMap args= ct.getArgumentMap(); assertEquals(1, args.size()); assertInstance(args.keyAt(0), ICPPTemplateNonTypeParameter.class); - + // non-type arguments are currently modelled as a type with attached expression ICPPBasicType bt= assertInstance(args.getAt(0), ICPPBasicType.class); assertEquals(bt.getType(), IBasicType.t_int); assertEquals(256, ct.getTemplateArguments()[0].getNonTypeValue().numericalValue().intValue()); - + ba.assertNonProblem("foo(t)", 3); ba.assertNonProblem("bar(t)", 3); } - + // template<int x> // class C {}; // @@ -3076,7 +3076,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertEquals(1, args.length); assertEquals(0, Value.isTemplateParameter(args[0].getNonTypeValue())); } - + // template<int x> // class A {}; // @@ -3085,7 +3085,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ba.assertProblem("A<int>", 6); } - + // template<int I> // class That { // public: @@ -3103,14 +3103,14 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testParameterReferenceInChainInitializer_a() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + // These intermediate assertions will not hold until deferred non-type arguments are // correctly modelled ICPPClassType tid= ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class); assertFalse(tid instanceof ICPPSpecialization); ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class); assertFalse(th1sCtor instanceof ICPPSpecialization); - + ICPPTemplateNonTypeParameter np = ba.assertNonProblem("I>(I)", 1, ICPPTemplateNonTypeParameter.class); ICPPConstructor clazz= ba.assertNonProblem("That<I>(I)", 4, ICPPConstructor.class); ICPPConstructor ctor= ba.assertNonProblem("That<I>(I)", 7, ICPPConstructor.class); @@ -3118,7 +3118,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateNonTypeParameter np1 = ba.assertNonProblem("I)", 1, ICPPTemplateNonTypeParameter.class); assertSame(np, np1); } - + // template<typename I> // class That { // public: @@ -3136,24 +3136,24 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testParameterReferenceInChainInitializer_b() throws Exception { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); - + ICPPClassType tid= ba.assertNonProblem("This<I>::T", 7, ICPPClassType.class); assertFalse(tid instanceof ICPPSpecialization); ICPPConstructor th1sCtor= ba.assertNonProblem("This() :", 4, ICPPConstructor.class); assertFalse(th1sCtor instanceof ICPPSpecialization); - + ICPPTemplateTypeParameter np= ba.assertNonProblem("I>()", 1, ICPPTemplateTypeParameter.class); ICPPConstructor clazz= ba.assertNonProblem("That<I>()", 4, ICPPConstructor.class); ICPPConstructor ctor= ba.assertNonProblem("That<I>()", 7, ICPPConstructor.class); } - + // template<typename T, int I> // class C {}; // // template<typename T> // class C<T, 5> {}; - // - // class A {}; + // + // class A {}; // // C<A,5L> ca5L; public void testIntegralConversionInPartialSpecializationMatching_237914() throws Exception { @@ -3161,7 +3161,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateInstance ctps= ba.assertNonProblem("C<A,5L>", 7, ICPPTemplateInstance.class, ICPPClassType.class); assertInstance(ctps.getTemplateDefinition(), ICPPClassTemplatePartialSpecialization.class); } - + // template<typename T, int I> // class C {}; // @@ -3181,7 +3181,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPSpecialization ctps= ba.assertNonProblem("C<A,5L>", 7, ICPPSpecialization.class, ICPPClassType.class); ba.assertNonProblem("test=", 4, ICPPField.class); } - + // class A { // public: // A(const A& a) {} @@ -3196,7 +3196,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ba.assertNonProblem("A(other", 1); } - + // class A {}; // // class B { @@ -3215,7 +3215,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ba.assertNonProblem("foo(s", 3); } - + // template <class T> // class A { // public: @@ -3231,7 +3231,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ba.assertNonProblem("foo();", 3); } - + // namespace result_of { // template <typename Sequence, typename T, bool is_associative_sequence = false> // struct find; @@ -3250,13 +3250,13 @@ public class AST2TemplateTests extends AST2BaseTest { // template <typename Sequence, typename T> // struct find<Sequence, T, true> { // typedef detail::assoc_find<Sequence, T> filter; - // }; + // }; // } public void testBug238180_ArrayOutOfBounds() throws Exception { // the code above used to trigger an ArrayOutOfBoundsException parse(getAboveComment(), ParserLanguage.CPP); } - + // namespace detail { // template<bool AtoB, bool BtoA, bool SameType, class A, class B> // struct str; @@ -3283,7 +3283,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPTemplateTypeParameter tp= (ICPPTemplateTypeParameter) spec.getTemplateParameters()[0]; assertNull(tp.getDefault()); } - + // class X { // template <typename S> X(S s); // }; @@ -3291,11 +3291,11 @@ public class AST2TemplateTests extends AST2BaseTest { // void test(X* a); // void bla(int g) { // test(new X(g)); - // } + // } public void testBug239586_ClassCast() throws Exception { parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); } - + // template<typename T1> class CT { // static int x; // }; @@ -3304,7 +3304,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ICPPTemplateTypeParameter t= ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class); } - + // template<class T1, T1 v1> // struct integral_constant { // static const T1 value = v1; @@ -3377,7 +3377,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true); ba.assertNonProblem("x))", 1, ICPPVariable.class); } - + // template<typename T, typename U> class TL {}; // typedef int T; // typedef @@ -3405,19 +3405,19 @@ public class AST2TemplateTests extends AST2BaseTest { } } }; - + t.start(); t.join(4000); assertFalse(t.isAlive()); if (th[0] != null) throw th[0]; } - + // template<class T, class U> class A {}; - // template<class T> class A<T, int> { - // void foo(T t); - // }; - // template<class T> void A<T, int>::foo(T t) {} + // template<class T> class A<T, int> { + // void foo(T t); + // }; + // template<class T> void A<T, int>::foo(T t) {} public void testBug177418() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true ); @@ -3436,7 +3436,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(A, col.getName(5).resolveBinding()); assertSame(T2, col.getName(6).resolveBinding()); - ICPPMethod foo = (ICPPMethod) col.getName(7).resolveBinding(); + ICPPMethod foo = (ICPPMethod) col.getName(7).resolveBinding(); assertSame(T2, col.getName(8).resolveBinding()); assertSame(T2, col.getName(10).resolveBinding()); ICPPParameter t = (ICPPParameter) col.getName(9).resolveBinding(); @@ -3448,7 +3448,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(T2, col.getName(16).resolveBinding()); assertSame(t, col.getName(17).resolveBinding()); } - + // template <typename T, typename U> class CT { // T* instance(void); // }; @@ -3458,7 +3458,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testNewOfThisTemplate() throws Exception { parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP); } - + // template <class T> void f(T); // class X { // friend void f<>(int); @@ -3474,7 +3474,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertInstance(fref2, ICPPTemplateInstance.class); assertSame(f, ((ICPPTemplateInstance) fref2).getSpecializedBinding()); } - + // template <typename T> class XT { // typedef int mytype1; // mytype1 m1(); @@ -3504,11 +3504,11 @@ public class AST2TemplateTests extends AST2BaseTest { m2= bh.assertNonProblem("m3() ", 2); assertSame(m1, m2); } - + // template<typename S> class A1 { // template<typename T> void f1(T); // }; - // template<> template<typename T> void A1<float>::f1(T){} + // template<> template<typename T> void A1<float>::f1(T){} // // template<typename T> class A {}; // template<> class A<float> { @@ -3525,12 +3525,12 @@ public class AST2TemplateTests extends AST2BaseTest { IBinding owner= method.getOwner(); assertInstance(owner, ICPPClassSpecialization.class); assertSame(A1, ((ICPPClassSpecialization) owner).getSpecializedBinding()); - + ICPPClassSpecialization special= bh.assertNonProblem("A<float>", 8); method= bh.assertNonProblem("A<float>::f", 11); assertSame(method.getOwner(), special); - } - + } + // template<typename T> class XT { // class Nested { // template<typename V> void Nested::m(V); @@ -3548,7 +3548,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(mt1, mt2); assertInstance(mt1, ICPPFunctionTemplate.class); } - + // template <typename T, typename U=T> class XT {}; // template <typename T> class XT<T,T> {public: int partial;}; // void test() { @@ -3559,7 +3559,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> class XT { // public: // int a; @@ -3577,7 +3577,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertInstance(a1, ICPPField.class); assertSame(a1, a2); } - + // void f(int); void f(char); // void g(int); // template<typename T> void h(T); @@ -3599,7 +3599,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("f(b)", 1, ICPPUnknownBinding.class, IFunction.class); bh.assertNonProblem("h(b)", 1, ICPPUnknownBinding.class, IFunction.class); bh.assertNonProblem("m(b)", 1, ICPPUnknownBinding.class, IFunction.class); - IFunction g= bh.assertNonProblem("g(b)", 1); + IFunction g= bh.assertNonProblem("g(b)", 1); assertFalse(g instanceof ICPPUnknownBinding); } @@ -3615,7 +3615,7 @@ public class AST2TemplateTests extends AST2BaseTest { // }; public void testTypeOfUnknownReferences_Bug257194a() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); bh.assertNonProblem("b.c", 1, ICPPUnknownBinding.class); @@ -3640,7 +3640,7 @@ public class AST2TemplateTests extends AST2BaseTest { // }; public void testTypeOfUnknownReferences_Bug257194b() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); bh.assertNonProblem("b->c", 1, ICPPUnknownBinding.class); @@ -3665,14 +3665,14 @@ public class AST2TemplateTests extends AST2BaseTest { // }; public void testTypeVsExpressionInArgsOfDependentTemplateID_257194() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPUnknownBinding b= bh.assertNonProblem("a>", 1); assertFalse(b instanceof IType); b= bh.assertNonProblem("A>", 1); assertTrue(b instanceof IType); - + ICPPUsingDeclaration ud= bh.assertNonProblem("b;", 1); b= (ICPPUnknownBinding) ud.getDelegates()[0]; assertFalse(b instanceof IType); @@ -3727,7 +3727,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); bh.assertNonProblem("A<B, int>", 9, ICPPConstructor.class); } - + // template <typename CL, typename T> // struct A { // template<typename U> struct C { @@ -3767,12 +3767,12 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testCtorWithTemplateID_259600() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPConstructor ctor= bh.assertNonProblem("DumbPtr/**/", 7); ICPPMethod dtor= bh.assertNonProblem("~DumbPtr/**/", 8); } - + // template <class T> class XT { // public: // template<typename X> XT(X*); @@ -3782,12 +3782,12 @@ public class AST2TemplateTests extends AST2BaseTest { // template <class T> template <class X> XT<T>::XT<T>/**/(X& a) {} public void testCtorTemplateWithTemplateID_259600() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPConstructor ctor= bh.assertNonProblem("XT/**/", 2); ctor= bh.assertNonProblem("XT<T>/**/", 5); } - + // template <typename T> class XT { // public: // typedef typename T::Nested TD; @@ -3806,7 +3806,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testResolutionOfUnknownBindings_262163() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); IVariable x= bh.assertNonProblem("x;", 1); ITypedef Nested= bh.assertNonProblem("Nested;", 6); @@ -3842,7 +3842,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); bh.assertNonProblem("substr(0)", 6, ICPPMethod.class); } - + // class C {}; // template<typename T> class XT { // T field; @@ -3855,7 +3855,7 @@ public class AST2TemplateTests extends AST2BaseTest { String code= getAboveComment(); parseAndCheckBindings(code); } - + // class C {}; // template<typename T> class XT { // T field; @@ -3868,7 +3868,7 @@ public class AST2TemplateTests extends AST2BaseTest { String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> class CT { // public: // void append(unsigned int __n, T __c) {} @@ -3925,7 +3925,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("A<C> make_A(C* p) {", 4, ICPPTemplateInstance.class); parseAndCheckBindings(code); } - + // template <typename T> class CT { // public: // template <typename U> CT(U u) {} @@ -3939,7 +3939,7 @@ public class AST2TemplateTests extends AST2BaseTest { String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> class XT {}; // template <typename T> void func(T t, XT<typename T::A> a) {} // template <typename T, typename S> void func(S s, XT<typename S::A> a, T t) {} @@ -3963,7 +3963,7 @@ public class AST2TemplateTests extends AST2BaseTest { // m(0); // ok with a conversion from 0 to T // } // }; - public void testUnknownParameter_264988() throws Exception { + public void testUnknownParameter_264988() throws Exception { String code= getAboveComment(); parseAndCheckBindings(code); } @@ -3975,11 +3975,11 @@ public class AST2TemplateTests extends AST2BaseTest { // // int x = A<0>::e; // A<0>::E y; - public void testEnumeratorInTemplateInstance_265070() throws Exception { + public void testEnumeratorInTemplateInstance_265070() throws Exception { String code= getAboveComment(); parseAndCheckBindings(code); } - + // template<typename T> class CT {}; // template<class T> CT<T>& getline1(CT<T>& __in); // template<class T> CT<T>& getline2(CT<T>& __in); @@ -3993,7 +3993,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("getline2(i)", 8, ICPPTemplateInstance.class); parseAndCheckBindings(code); } - + // class C { // friend int f1(int); // }; @@ -4003,8 +4003,8 @@ public class AST2TemplateTests extends AST2BaseTest { // template <typename T1> class C1 { // template <typename T2> class C2 { // template<typename T3> class C3 { - // }; - // }; + // }; + // }; // }; public void testOwnerOfFriendTemplate_265671() throws Exception { final String code = getAboveComment(); @@ -4017,17 +4017,17 @@ public class AST2TemplateTests extends AST2BaseTest { assertNull(owner); ICPPTemplateParameter tpar= ft.getTemplateParameters()[0]; assertEquals(0, tpar.getTemplateNestingLevel()); - + tpar= bh.assertNonProblem("T1", 2, ICPPTemplateParameter.class); assertEquals(0, tpar.getTemplateNestingLevel()); tpar= bh.assertNonProblem("T2", 2, ICPPTemplateParameter.class); assertEquals(1, tpar.getTemplateNestingLevel()); tpar= bh.assertNonProblem("T3", 2, ICPPTemplateParameter.class); assertEquals(2, tpar.getTemplateNestingLevel()); - + parseAndCheckBindings(code); } - + // template <typename T> void f(T t) { // g(t); // } @@ -4038,10 +4038,10 @@ public class AST2TemplateTests extends AST2BaseTest { IFunction gref= bh.assertNonProblem("g(t)", 1); assertInstance(gref, ICPPUnknownBinding.class); IFunction gdecl= bh.assertNonProblem("g(T t)", 1); - + parseAndCheckBindings(code); } - + // class C; // C* c(void*) {return 0;} // @@ -4062,7 +4062,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code); } - + // template<typename T> class XT { // operator T() {return 0;} // void m() { @@ -4074,7 +4074,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> class X {}; // template <typename T> class X1 { // friend class X<T>; @@ -4086,7 +4086,7 @@ public class AST2TemplateTests extends AST2BaseTest { // }; public void testFriendClassTemplate_266992() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); } // template <int N> @@ -4098,7 +4098,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testFunctionTemplateWithArrayReferenceParameter_269926() throws Exception { final String code = getAboveComment(); - parseAndCheckBindings(code); + parseAndCheckBindings(code); } // template <typename T> @@ -4138,7 +4138,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code); } - + // template<unsigned int> struct ST{}; // template<template<unsigned int> class T> class CT {}; // typedef CT<ST> TDef; @@ -4146,17 +4146,17 @@ public class AST2TemplateTests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code); } - + // template <int N> void T(int (&array)[N]) {}; // void test() { // int a[2]; - // T<2>(a); + // T<2>(a); // } public void testInstantiationOfArraySize_269926() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> class CT { // void init(); // }; @@ -4181,7 +4181,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code = getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> // struct A { // typedef A<T> Self; @@ -4202,7 +4202,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPFunction func= bh.assertNonProblem("f(x)", 1, ICPPFunction.class); assertFalse(func instanceof ICPPUnknownBinding); } - + // class NullType {}; // template <typename T, typename U> struct TypeList { // typedef T Head; @@ -4220,7 +4220,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template<typename T> class XT { // void n() { // m(); // ok @@ -4236,7 +4236,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertFalse(func instanceof ICPPUnknownBinding); bh.assertProblem("n();", 1); } - + // template<class T> struct CT {}; // class D : public CT<char> {}; // template<typename S> void f1(const CT<S> &) {} @@ -4264,7 +4264,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("f4(i);", 2, ICPPFunction.class); bh.assertProblem("f3(&cd);", 2); } - + // template<typename T> struct C {}; // template<typename T, typename V> void f(T, C<V>) {} // template<typename T> void f(T, C<int>) {} @@ -4280,7 +4280,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> void func(T* t) {}; // template <typename T> void func(T& t) {}; // void test() { @@ -4298,7 +4298,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template<typename T> class CT {}; // template<int I> class CTI {}; // @@ -4323,7 +4323,7 @@ public class AST2TemplateTests extends AST2BaseTest { // } public void testClosingAngleBrackets2_261268() throws Exception { final String code= getAboveComment(); - IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false); + IASTTranslationUnit tu = parse(code, ParserLanguage.CPP, true, false); IASTFunctionDefinition fdef= getDeclaration(tu, 2); IASTProblemStatement p1= getStatement(fdef, 1); } @@ -4342,7 +4342,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // #define OPASSIGN(x) x##= // int test() { // int a=1; @@ -4352,7 +4352,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <class T> class X { // void f(const T&); // void g(T&&); @@ -4382,7 +4382,7 @@ public class AST2TemplateTests extends AST2BaseTest { m= ms[1-i]; assertEquals("const int &&", ASTTypeUtil.getType(m.getType().getParameterTypes()[0])); } - + // template<typename... Pack> void f1(int (* p)(Pack ...a)); // template<typename... Pack> void f2(int (* ...p)(Pack a, int)); // template<typename... Pack> void f3(Pack (* ...p)()); @@ -4426,16 +4426,16 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPClassTemplate ct= bh.assertNonProblem("C1", 2); ICPPTemplateParameter tp= ct.getTemplateParameters()[0]; assertTrue(tp.isParameterPack()); - + ct= bh.assertNonProblem("C2", 2); tp= ct.getTemplateParameters()[0]; assertTrue(tp.isParameterPack()); - + ct= bh.assertNonProblem("C3", 2); tp= ct.getTemplateParameters()[0]; assertTrue(tp.isParameterPack()); } - + // template <typename... Pack> class CT : public Pack... { // void mem() throw(Pack...); // }; @@ -4460,7 +4460,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertEquals(2, spec.length); assertEquals("A", ASTTypeUtil.getType(spec[0])); assertEquals("B", ASTTypeUtil.getType(spec[1])); - } + } // template<typename... T> void f1(T*...); // template<typename T> void f2(T*...); @@ -4471,12 +4471,12 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPFunctionTemplate ft= bh.assertNonProblem("f1", 2); ICPPTemplateParameter tp= ft.getTemplateParameters()[0]; assertTrue(tp.isParameterPack()); - + ft= bh.assertNonProblem("f2", 2); tp= ft.getTemplateParameters()[0]; assertFalse(tp.isParameterPack()); - } - + } + // template <int ...I> struct CTx {}; // void test() { // CTx<> a; @@ -4494,7 +4494,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909a() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<typename... T> void f(T (* ...t)(int, int)); // int add(int, int); @@ -4505,7 +4505,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909b() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<typename... Mixins> // class X : public Mixins... @@ -4515,14 +4515,14 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909c() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<class... Types> class Tuple; // Types is a template type parameter pack // template<class T, int... Dims> struct multi array; // Dims is a non-type template parameter pack public void testVariadicTemplateExamples_280909d() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<class T = char> class String; // String<>* p; // OK: String<char> @@ -4537,7 +4537,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertProblem("String*", 6); bh.assertNonProblem("Tuple<>", 5); bh.assertProblem("Tuple*", 5); - } + } // template<class T> class A {}; // template<class T, class U = T> class B {}; @@ -4559,13 +4559,13 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("Y<A>", 4); bh.assertNonProblem("Y<B>", 4); bh.assertNonProblem("Y<C>", 4); - } + } - // template<class T1, class T2> struct A { + // template<class T1, class T2> struct A { // void f1(); // void f2(); // }; - // template<class... Types> struct B { + // template<class... Types> struct B { // void f3(); // void f4(); // }; @@ -4580,7 +4580,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertProblem("f2() {}", 2); bh.assertNonProblem("f3() {}", 2); bh.assertProblem("f4() {}", 2); - } + } // template<class X, class Y> X f(Y); // template<class X, class Y, class... Z> X g(Y); @@ -4603,7 +4603,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertProblem("f<void>(f<int>)", 7); bh.assertNonProblem("g<int>(5.6)", 6); bh.assertNonProblem("f<void>(g<int, bool>)", 7); - } + } // template<class X, class Y, class Z> X f(Y,Z); // template<class... Args> void f2(); @@ -4623,7 +4623,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("f<int>", 0); bh.assertProblem("f(\"aa\",3.0)", 1); bh.assertNonProblem("f2<char, short, int, long>", 0); - } + } // template<typename... Types> void f(Types... values); // void g() { @@ -4632,7 +4632,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909j() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<class... Types> void f(Types&...); // template<class T1, class... Types> void g(T1, Types...); @@ -4640,11 +4640,11 @@ public class AST2TemplateTests extends AST2BaseTest { // const int z = x; // f(x, y, z); // Types is deduced to int, float, const int // g(x, y, z); // T1 is deduced to int, Types is deduced to float, int - // } + // } public void testVariadicTemplateExamples_280909k() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<class> struct X { }; // template<class R, class... ArgTypes> struct X<R(int, ArgTypes...)> { }; @@ -4662,7 +4662,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909n() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<typename... Types> struct Tuple { }; // void test() { @@ -4678,7 +4678,7 @@ public class AST2TemplateTests extends AST2BaseTest { bh.assertNonProblem("Tuple<int>", 0); bh.assertNonProblem("Tuple<int, float>", 0); bh.assertProblem("Tuple<0>", 0); - } + } // template<typename... Types> void f(Types... args); // void test() { @@ -4689,7 +4689,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909q() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<typename... Types> void f(Types... rest); // template<typename... Types> void g(Types... rest) { @@ -4698,18 +4698,18 @@ public class AST2TemplateTests extends AST2BaseTest { public void testVariadicTemplateExamples_280909r() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } + } // template<typename...> struct Tuple {}; // template<typename T1, typename T2> struct Pair {}; - // template<typename... Args1> struct zip { - // template<typename... Args2> struct with { + // template<typename... Args1> struct zip { + // template<typename... Args2> struct with { // typedef Tuple<Pair<Args1, Args2>...> type; // }; // }; // typedef zip<short, int>::with<unsigned short, unsigned>::type T1; // // T1 is Tuple<Pair<short, unsigned short>, Pair<int, unsigned> > - // typedef zip<short>::with<unsigned short, unsigned>::type T2; + // typedef zip<short>::with<unsigned short, unsigned>::type T2; // // error: different number of arguments specified // // for Args1 and Args2 // template<typename... Args> void f(Args... args) {} @@ -4735,8 +4735,8 @@ public class AST2TemplateTests extends AST2BaseTest { ub= bh.assertNonProblem("f(5 ...)", 1); // no diagnostics in CDT, treated as unknown function. ub= bh.assertNonProblem("f(args)", 1); // no diagnostics in CDT ub= bh.assertNonProblem("f(h(args...) + args...)", 1); - } - + } + // struct Test { // void Update() {} // }; @@ -4750,7 +4750,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <class T, class U = double> void f(T t = 0, U u = 0); // void g() { // f(1, 'c'); // f<int,char>(1,'c') @@ -4762,7 +4762,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDefaultTemplateArgsForFunctionTemplates_294730() throws Exception { final String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - + ICPPTemplateInstance f= bh.assertNonProblem("f(1, 'c');", 1); assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true)); f= bh.assertNonProblem("f(1);", 1); @@ -4773,7 +4773,7 @@ public class AST2TemplateTests extends AST2BaseTest { f= bh.assertNonProblem("f<int,char>();", -3); assertEquals("<int,char>", ASTTypeUtil.getArgumentListString(f.getTemplateArguments(), true)); } - + // template<typename T> class CT {}; // extern template class CT<int>; public void testExternTemplates_294730() throws Exception { @@ -4782,7 +4782,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPASTExplicitTemplateInstantiation ti= getDeclaration(tu, 1); assertEquals(ICPPASTExplicitTemplateInstantiation.EXTERN, ti.getModifier()); } - + // template <class T> struct eval; // template <template <class, class...> class TT, class T1, class... Rest> // struct eval<TT<T1, Rest...>> { }; @@ -4802,19 +4802,19 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPClassTemplate ct= bh.assertNonProblem("eval;", -1); ICPPClassTemplatePartialSpecialization pspec= bh.assertNonProblem("eval<TT<T1, Rest...>>", 0); - + ICPPTemplateInstance inst= bh.assertNonProblem("eval<A<int>>", 0); assertSame(pspec, inst.getSpecializedBinding()); - + inst= bh.assertNonProblem("eval<B<int, float>>", 0); assertSame(pspec, inst.getSpecializedBinding()); - + inst= bh.assertNonProblem("eval<C<17>>", 0); assertSame(ct, inst.getSpecializedBinding()); - + inst= bh.assertNonProblem("eval<D<int, 17>>", 0); assertSame(ct, inst.getSpecializedBinding()); - + inst= bh.assertNonProblem("eval<E<int, float>>", 0); assertSame(ct, inst.getSpecializedBinding()); } @@ -4834,13 +4834,13 @@ public class AST2TemplateTests extends AST2BaseTest { public void testExplicitSpecializations_296427() throws Exception { final String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - + ICPPTemplateInstance inst; inst= bh.assertNonProblem("X<int>", 0); assertFalse(inst.isExplicitSpecialization()); inst = bh.assertNonProblem("Y<int> y;", 6); assertTrue(inst.isExplicitSpecialization()); - + inst = bh.assertNonProblem("f(1)", 1); assertFalse(inst.isExplicitSpecialization()); inst = bh.assertNonProblem("g(1)", 1); @@ -4860,7 +4860,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <typename T> struct CT; // template<> struct CT<int> {typedef int Type;}; // template <typename T> struct CT <const T> { @@ -4893,7 +4893,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(code, true); bh.assertProblem("func<int*>", 0); } - + // template <typename T> struct CT { // typedef int T1; // }; @@ -4909,7 +4909,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template<typename T1, typename T2> class CT {}; // template<> class CT<int,char> {}; // template<> class CT<char,char> {}; @@ -4939,7 +4939,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertEquals(1, names.length); assertEquals("CT<char, char>", names[0].toString()); } - + public void testBug316704() throws Exception { StringBuilder code= new StringBuilder("typedef if_< bool,"); for (int i = 0; i < 50; i++) { @@ -4989,7 +4989,7 @@ public class AST2TemplateTests extends AST2BaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPFunctionTemplate ft= bh.assertNonProblem("f(T&)", 1); ICPPNamespace M= (ICPPNamespace) ft.getOwner(); - + ICPPTemplateInstance inst; inst= bh.assertNonProblem("f<char>", 0); assertSame(ft, inst.getTemplateDefinition()); @@ -5007,7 +5007,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(ft, inst.getTemplateDefinition()); assertSame(M, inst.getOwner()); } - + // template <class T> struct A { // friend void f(A, T){} // }; @@ -5023,7 +5023,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template <class T> class X { }; // template <class T> void f(T t) { } // struct {} unnamed_obj; @@ -5043,7 +5043,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // struct S { // int s; // }; @@ -5059,8 +5059,8 @@ public class AST2TemplateTests extends AST2BaseTest { public void testOverloadResolutionBetweenMethodTemplateAndFunction() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } - + } + // template<typename ...T> void f(T..., T...); // void test() { // f(1,1); @@ -5068,8 +5068,8 @@ public class AST2TemplateTests extends AST2BaseTest { public void testFunctionParameterPacksInNonFinalPosition_324096() throws Exception { final String code= getAboveComment(); parseAndCheckBindings(code); - } - + } + // template<typename _CharT> struct OutStream { // OutStream& operator<<(OutStream& (*__pf)(OutStream&)); // }; @@ -5078,20 +5078,20 @@ public class AST2TemplateTests extends AST2BaseTest { // void test() { // OutStream<char> out; // out << endl; - // } + // } public void testInstantiationOfEndl_297457() throws Exception { final String code= getAboveComment(); IASTTranslationUnit tu= parseAndCheckBindings(code); final IASTNodeSelector nodeSelector = tu.getNodeSelector(null); - + IASTName methodName= nodeSelector.findEnclosingName(code.indexOf("operator<<"), 1); IASTImplicitName name = nodeSelector.findImplicitName(code.indexOf("<< endl"), 2); - + final IBinding method = methodName.resolveBinding(); final IBinding reference = name.resolveBinding(); assertSame(method, ((ICPPSpecialization) reference).getSpecializedBinding()); } - + // template<typename T> bool MySort(const T& a); // bool MySort(const int& a); // template<typename V> void sort(V __comp); @@ -5101,7 +5101,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testAdressOfUniqueTemplateInst_Bug326076() throws Exception { parseAndCheckBindings(); } - + // template <typename T> void f(T (*)(int), char); // template <typename T> void f(int (*)(T), int); // template <typename T> void f(T, int); @@ -5126,14 +5126,14 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(f1, t.getTemplateDefinition()); t= bh.assertNonProblem("f(g, 1)", 1); assertSame(f2, t.getTemplateDefinition()); - + ICPPFunction g; g= bh.assertNonProblem("g, '1')", 1); assertSame(g2, g); g= bh.assertNonProblem("g, 1)", 1); assertSame(g1, g); } - + // template <class T> class Ptr{}; // namespace ns { // class T {}; @@ -5146,7 +5146,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testADLForTemplateSpecializations_Bug327069() throws Exception { parseAndCheckBindings(); } - + // template<typename T, typename V> T* f(V*); // template<typename T, typename V> T f(V*); // template<typename T, typename V> T* f(V); @@ -5156,7 +5156,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testPartialOrderingInNonCallContext_Bug326900() throws Exception { parseAndCheckBindings(); } - + // struct X { // template<typename T> operator T(); // template<typename T> operator T*(); @@ -5168,7 +5168,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testPartialOrderingForConversions_Bug326900() throws Exception { parseAndCheckBindings(); } - + // struct S { int foo; }; // template<typename T> struct L { // typedef T& CR; @@ -5188,7 +5188,7 @@ public class AST2TemplateTests extends AST2BaseTest { IBinding f2= bh.assertNonProblem("foo =", 3); assertSame(f1, f2); } - + // template <class T> struct TestTmpl { // struct Inner1; // struct Inner2{ @@ -5206,7 +5206,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testSpecializationViaNotDirectlyEnclosingTemplate_Bug333186() throws Exception { parseAndCheckBindings(); } - + // template <typename T> struct A { // typedef T type; // }; @@ -5219,14 +5219,14 @@ public class AST2TemplateTests extends AST2BaseTest { public void testNonTypeTemplateParameterWithTypenameKeyword_Bug333186() throws Exception { parseAndCheckBindings(); } - + // template <typename T, typename U = int> void f() { - // f<int>(); + // f<int>(); // } public void testDefaultTmplArgumentOfFunctionTemplate_Bug333325() throws Exception { parseAndCheckBindings(); } - + // template <void (*Func)()> class X {}; // template <typename T> void Y(); // X< Y<int> > x; @@ -5259,7 +5259,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void _testFunctionInstanceAsTemplateArg_Bug334472() throws Exception { parseAndCheckBindings(); } - + // template <typename T> void g() {} // template <typename T, typename U> void g() {} // void test() { @@ -5269,7 +5269,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testFunctionTemplateSignatures_Bug335062() throws Exception { parseAndCheckBindings(); } - + // template <bool B, class T = void> struct enable_if { // typedef T type; // }; @@ -5291,27 +5291,27 @@ public class AST2TemplateTests extends AST2BaseTest { public void testSyntaxErrorInReturnTypeOfFunctionInstance_Bug336426() throws Exception { parseAndCheckBindings(); } - + // template <typename T> struct A {}; // template <typename Functor> void f(Functor functor) { - // A<decltype(functor())> a; + // A<decltype(functor())> a; // } public void testFunctionCallOnDependentName_Bug337686() throws Exception { parseAndCheckBindings(); } - + // struct S {}; // template <typename... Args> void h(S s, Args... args) {} // void g() { // S s; // h(s); - // h(s, 1); - // h(s, 1, 2); + // h(s, 1); + // h(s, 1, 2); // } public void testVariadicFunctionTemplate_Bug333389() throws Exception { parseAndCheckBindings(); } - + // template<typename T> void f(T(*)()); // template<typename T> void g(T(*)(void)); // void v1(); @@ -5325,7 +5325,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testFunctionWithVoidParamInTypeDeduction() throws Exception { parseAndCheckBindings(); } - + // template<typename T, unsigned length> struct Templ { // Templ(){} // }; @@ -5347,8 +5347,8 @@ public class AST2TemplateTests extends AST2BaseTest { public void testPartialSpecAfterExplicitInst_339475() throws Exception { parseAndCheckBindings(); } - - + + // template<bool> struct S { // static int m(); // }; @@ -5365,7 +5365,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateIDAmbiguity_341747a() throws Exception { IASTTranslationUnit tu= parseAndCheckBindings(); IASTFunctionDefinition fdef= getDeclaration(tu, 4); - + IASTExpressionStatement stmt; stmt= getStatement(fdef, 0); assertTrue(stmt.getExpression() instanceof IASTBinaryExpression); @@ -5379,7 +5379,7 @@ public class AST2TemplateTests extends AST2BaseTest { stmt= getStatement(fdef, 0); assertTrue(stmt.getExpression() instanceof IASTBinaryExpression); } - + // const int a=0, b=1; // template<int> struct A{}; // @@ -5391,7 +5391,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateIDAmbiguity_341747b() throws Exception { parseAndCheckBindings(); } - + // int a=0, b=1; // bool bl= false; // template<bool B> struct S { @@ -5404,7 +5404,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateIDAmbiguity_341747c() throws Exception { parseAndCheckBindings(); } - + // struct S { // int B; // }; @@ -5417,7 +5417,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateIDAmbiguity_341747d() throws Exception { parseAndCheckBindings(); } - + // template<typename T> void ft(void (T::* function)()) {} // struct Bar { // template<typename T> Bar(void (T::*function)()) {} @@ -5434,7 +5434,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testAddressOfMethodForInstantiation_Bug344310() throws Exception { parseAndCheckBindings(); } - + // template<typename Arg> struct Callback { // Callback(void (*function)(Arg arg)) {} // }; @@ -5448,7 +5448,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testParameterAdjustementInInstantiatedFunctionType_351609() throws Exception { parseAndCheckBindings(); } - + // template<typename T> struct CT { // int g; // }; @@ -5471,7 +5471,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateParameterWithoutName_352266() throws Exception { parseAndCheckBindings(); } - + // template<template<typename, typename...> class T> struct CTTP{ }; // // template<typename T> struct CT1{ }; @@ -5488,7 +5488,7 @@ public class AST2TemplateTests extends AST2BaseTest { } // template<typename T> T f(); - // template<> int f() { + // template<> int f() { // return 0; // } public void testArgumentDeductionFromReturnTypeOfExplicitSpecialization_355304() throws Exception { @@ -5540,7 +5540,7 @@ public class AST2TemplateTests extends AST2BaseTest { } // template<typename T> struct SS {}; - // template<template<typename T, typename S = SS<T> > class Cont> + // template<template<typename T, typename S = SS<T> > class Cont> // Cont<int> f() {} public void testReferenceToParameterOfTemplateTemplateParameter_357308() throws Exception { parseAndCheckBindings(); @@ -5548,8 +5548,8 @@ public class AST2TemplateTests extends AST2BaseTest { // template <typename...> void f() {} // void test() { - // f(); - // f<>(); + // f(); + // f<>(); // } public void testTemplateArgumentDeductionWithoutParameters_358654() throws Exception { parseAndCheckBindings(); @@ -5569,7 +5569,7 @@ public class AST2TemplateTests extends AST2BaseTest { // typedef B u; // }; // - // struct C8 { char c[8]; }; + // struct C8 { char c[8]; }; // // typedef C<sizeof(char) == sizeof(C8), B> r; // typedef r::s t; @@ -5578,7 +5578,7 @@ public class AST2TemplateTests extends AST2BaseTest { final String code= getAboveComment(); parseAndCheckBindings(code); } - + // template<typename T> struct B { // void m(); // }; @@ -5590,7 +5590,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDependentUsingDeclaration() throws Exception { parseAndCheckBindings(); } - + // template <int> void* foo(int); // template <typename T> void f(T t) { // if (T* i = foo<0>(0)) @@ -5599,7 +5599,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDirectlyNestedAmbiguity_362976() throws Exception { parseAndCheckBindings(); } - + // template<typename T, T p1, T p2, T p3=T(), T p4=T(), T p5=T(), // T p6=T(), T p7=T(), T p8=T(), T p9=T(), T p10=T(), // T p11=T(), T p12=T(), T p13=T(), T p14=T(), T p15=T(), @@ -5621,7 +5621,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testNestedTemplateAmbiguity_363609() throws Exception { parseAndCheckBindings(); } - + // struct A { // void m() {} // }; @@ -5632,7 +5632,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDefaultArgForNonTypeTemplateParameter_363743() throws Exception { parseAndCheckBindings(); } - + // template<class T> struct A { // bool b; // }; @@ -5654,7 +5654,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateAmbiguityInDeleteExpression_364225() throws Exception { parseAndCheckBindings(); } - + // template <typename T> void foo(T); // template <typename T> void foo(T, typename T::type* = 0); // int main() { @@ -5663,11 +5663,11 @@ public class AST2TemplateTests extends AST2BaseTest { public void testSyntaxFailureInstantiatingFunctionTemplate_365981a() throws Exception { parseAndCheckBindings(); } - + // template <typename T> bool bar(T); // template <typename T> bool bar(T, void(T::*)() = 0); // void test() { - // bar(0); + // bar(0); // } public void testSyntaxFailureInstantiatingFunctionTemplate_365981b() throws Exception { parseAndCheckBindings(); @@ -5684,7 +5684,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testResolvingAutoTypeWithDependentExpression_367472() throws Exception { parseAndCheckBindings(); } - + // void foo(int, int); // template <typename... Args> void bar(Args... args) { // foo(1,2,args...); @@ -5693,7 +5693,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testPackExpansionsAsArguments_367560() throws Exception { parseAndCheckBindings(); } - + // template <typename> class A; // template <typename T> class A<void (T::*)()> {}; // template <typename T> class A<void (T::*)() const> {}; @@ -5705,7 +5705,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testDeductionForConstFunctionType_367562() throws Exception { parseAndCheckBindings(); } - + // template <typename> struct base { // typedef int type; // }; @@ -5719,7 +5719,7 @@ public class AST2TemplateTests extends AST2BaseTest { ICPPDeferredClassInstance shortHand= bh.assertNonProblem("derived:", -1); assertTrue(shortHand.getClassTemplate() instanceof ICPPClassTemplatePartialSpecialization); } - + // template <typename> class A {}; // template <typename T, typename=void> struct B {}; // template <typename T> struct B<A<T> > { @@ -5729,7 +5729,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testPartialClassTemplateSpecUsingDefaultArgument_367997() throws Exception { parseAndCheckBindings(); } - + // struct two { char x[2]; }; // two check(...); // char check(int); @@ -5739,7 +5739,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testValueForSizeofExpression_368309() throws Exception { parseAndCheckBindings(); } - + // template <class Value> struct iterator { // Value operator*(); // }; @@ -5767,7 +5767,7 @@ public class AST2TemplateTests extends AST2BaseTest { assertEquals("A<S>::iterator_t", ASTTypeUtil.getType(v.getType(), true)); parseAndCheckBindings(); } - + // struct S { // int x; // }; @@ -5785,7 +5785,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testSpecializationOfClassType_368610a() throws Exception { parseAndCheckBindings(); } - + // struct S { // int x; // }; @@ -5803,7 +5803,7 @@ public class AST2TemplateTests extends AST2BaseTest { public void testSpecializationOfClassType_368610b() throws Exception { parseAndCheckBindings(); } - + // template <template<typename T> class TT> struct CTT { // int y; // }; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index d76d3e9fbdf..c4569410688 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -7038,7 +7038,7 @@ public class AST2Tests extends AST2BaseTest { // newArray var5; // // void foo() { - // /* The type of the arraysubscript expression should be struct s + // /* The type of the array subscript expression should be struct s // * each of the following statements // */ // var1[1].a = 1; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java index 2055a2a7117..5c8787373ae 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/FieldHandle.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.model.ext; @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core.model.IField { - private ASTAccessVisibility fVisibility; private String fTypeName; private boolean fIsStatic; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java index 2a4cf858a75..b17b1667a35 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTUnaryExpression.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation + * John Camelon (IBM Rational Software) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -142,7 +142,8 @@ public interface IASTUnaryExpression extends IASTExpression { * <code>OPERAND</code> represents the relationship between an <code>IASTUnaryExpression</code> and * it's nested <code>IASTExpression</code>. */ - public static final ASTNodeProperty OPERAND = new ASTNodeProperty("IASTUnaryExpression.OPERAND - IASTExpression (operand) for IASTUnaryExpression"); //$NON-NLS-1$ + public static final ASTNodeProperty OPERAND = + new ASTNodeProperty("IASTUnaryExpression.OPERAND - IASTExpression (operand) for IASTUnaryExpression"); //$NON-NLS-1$ /** * Get the operand. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java index dff76ed18e6..add0f8205b9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java @@ -19,6 +19,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionT import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType; +import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.COND_TDEF; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; @@ -40,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; @@ -260,15 +262,16 @@ public class CPPASTFunctionCallExpression extends ASTNode @Override public IType getExpressionType() { // Handle explicit type conversion in functional notation. - IType t= isExplicitTypeConversion(); - if (t != null) { - if (t instanceof IProblemBinding) { + IType type= isExplicitTypeConversion(); + if (type != null) { + if (type instanceof IProblemBinding) { return ProblemType.UNRESOLVED_NAME; } - return prvalueType(t); + return prvalueType(type); } - t= SemanticUtil.getNestedType(functionName.getExpressionType(), TDEF | REF | CVTYPE); + type= SemanticUtil.getNestedType(functionName.getExpressionType(), COND_TDEF | REF | CVTYPE); + IType t = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE); if (t instanceof ICPPClassType) { if (overload == UNINITIALIZED_FUNCTION) { overload = CPPSemantics.findOverloadedOperator(this, (ICPPClassType) t); @@ -283,9 +286,16 @@ public class CPPASTFunctionCallExpression extends ASTNode t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE); } if (t instanceof IFunctionType) { - return typeFromReturnType(((IFunctionType) t).getReturnType()); + type = typeFromReturnType(((IFunctionType) t).getReturnType()); + if (functionName instanceof ICPPASTFieldReference) { + IType ownerType = ((ICPPASTFieldReference) functionName).getFieldOwnerType(); + t = SemanticUtil.substituteTypedef(type, ownerType); + if (t != null) + type = t; + } + return type; } - if (CPPTemplates.isDependentType(t)) + if (CPPTemplates.isDependentType(type)) return CPPUnknownClass.createUnnamedInstance(); return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java index 74b9893f88a..968a156ab8c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java @@ -50,7 +50,8 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP this(orig, owner, argMap, null); } - public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap, ICPPClassSpecialization context) { + public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap, + ICPPClassSpecialization context) { super(orig, owner, argMap); fContext= context; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java index 962e2fd4e01..a7eccc21f35 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodSpecialization.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -24,31 +24,31 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; /** * The specialization of a method in the context of a class-specialization. */ -public class CPPMethodSpecialization extends CPPFunctionSpecialization - implements ICPPMethod { +public class CPPMethodSpecialization extends CPPFunctionSpecialization implements ICPPMethod { - public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap ) { - super(orig, owner, argMap ); + public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap) { + super(orig, owner, argMap); } @Override public boolean isVirtual() { ICPPMethod f = (ICPPMethod) getSpecializedBinding(); - if( f != null ) + if (f != null) return f.isVirtual(); IASTNode definition = getDefinition(); - if( definition != null ){ + if (definition != null) { IASTNode node = definition.getParent(); - while( node instanceof IASTDeclarator ) + while(node instanceof IASTDeclarator) node = node.getParent(); ICPPASTDeclSpecifier declSpec = null; - if( node instanceof IASTSimpleDeclaration ) - declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)node).getDeclSpecifier(); - else if( node instanceof IASTFunctionDefinition ) - declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)node).getDeclSpecifier(); + if (node instanceof IASTSimpleDeclaration) { + declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) node).getDeclSpecifier(); + } else if (node instanceof IASTFunctionDefinition) { + declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) node).getDeclSpecifier(); + } - if( declSpec != null ){ + if (declSpec != null) { return declSpec.isVirtual(); } } @@ -58,7 +58,7 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization @Override public int getVisibility() { ICPPMethod f = (ICPPMethod) getSpecializedBinding(); - if( f != null ) + if (f != null) return f.getVisibility(); return 0; } @@ -73,13 +73,13 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization char[] name = getNameCharArray(); if (name.length > 1 && name[0] == '~') return true; - + return false; } @Override public boolean isExplicit() { - return ((ICPPMethod)getSpecializedBinding()).isExplicit(); + return ((ICPPMethod) getSpecializedBinding()).isExplicit(); } @Override |