diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java index 07d69fe1a73..ea8df262477 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java @@ -2975,6 +2975,9 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest @Override public ITreeRoot getTreeRoot() throws BuildException { + if (getValueType() != TREE) { + throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ + } if (treeRoot == null) { if (superClass != null) { return superClass.getTreeRoot(); @@ -2982,9 +2985,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest return null; } } - if (getValueType() != TREE) { - throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ - } return treeRoot; } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java index 8d204ec1f7f..34a8ce00fdd 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/wizards/MBSWizardHandler.java @@ -271,6 +271,29 @@ public class MBSWizardHandler extends CWizardHandler { return out; } + /** + * Get a map from toolchain names to actual toolchains. + * This list should mirror the list displayed in the wizard. + * Bug #363612 + * + * @since 8.1 + * @return the map + */ + public SortedMap getToolChains() { + Set toolChainNames = this.tc_filter(); + SortedMap toolChainMap = new TreeMap(); + + for (String toolChainName : toolChainNames) { + IToolChain tc = tcs.get(toolChainName); + if (tc == null) { + toolChainMap.put(toolChainName, null); + } else { + toolChainMap.put(tc.getUniqueRealName(), tc); + } + } + return toolChainMap; + } + /** * Checks whether given toolchain can be displayed * @@ -708,6 +731,30 @@ public class MBSWizardHandler extends CWizardHandler { else return entryInfo.tc_filter().size(); } + /** + * Get a map from toolchain names to actual toolchains. + * Bug #363612 + * + * @since 8.1 + * @return the map + */ + public SortedMap getToolChains() { + if (entryInfo == null) + return full_tcs; + else + return entryInfo.getToolChains(); + } + /** + * Get the table that is displayed in the left pane. + * This allow for changes after handler creation. + * Bug #363612 + * + * @since 8.1 + * @return the table + */ + public Table getToolChainsTable() { + return table; + } public String getPropertyId() { return propertyId; } diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java index f73999e63a0..ef69af9fe9c 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ClassMembersInitializationChecker.java @@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition; @@ -43,6 +44,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags; import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; @@ -171,9 +174,13 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker { Set actualConstructorFields = constructorsStack.peek(); if (!actualConstructorFields.isEmpty()) { IBinding binding = name.resolveBinding(); - if (actualConstructorFields.contains(binding)) { - if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) { - actualConstructorFields.remove(binding); + if (binding != null && !(binding instanceof IProblemBinding)) { + IField equivalentFieldBinding = getContainedEquivalentBinding( + actualConstructorFields, binding, name.getTranslationUnit().getIndex()); + if (equivalentFieldBinding != null) { + if ((CPPVariableReadWriteFlags.getReadWriteFlags(name) & PDOMName.WRITE_ACCESS) != 0) { + actualConstructorFields.remove(equivalentFieldBinding); + } } } } @@ -181,6 +188,36 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker { return PROCESS_CONTINUE; } + private IField getContainedEquivalentBinding(Iterable fields, IBinding binding, IIndex index) { + for (IField field : fields) { + if (areEquivalentBindings(binding, field, index)) { + return field; + } + } + + return null; + } + + private boolean areEquivalentBindings(IBinding binding1, IBinding binding2, IIndex index) { + if (binding1.equals(binding2)) { + return true; + } + if ((binding1 instanceof IIndexBinding) != (binding2 instanceof IIndexBinding) && index != null) { + if (binding1 instanceof IIndexBinding) { + binding2 = index.adaptBinding(binding2); + } else { + binding1 = index.adaptBinding(binding1); + } + if (binding1 == null || binding2 == null) { + return false; + } + if (binding1.equals(binding2)) { + return true; + } + } + return false; + } + /** Checks whether class member of the specified type should be initialized * * @param type Type to check diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java index 55a23193970..40b6a97aa6f 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ClassMembersInitializationCheckerTest.java @@ -543,4 +543,28 @@ public class ClassMembersInitializationCheckerTest extends CheckerTestCase { loadCodeAndRun(getAboveComment()); checkNoErrors(); } + + //@file:test.h + //template + //struct B; + + //@file:test.cpp + //#include "test.h" + // + //template + //struct A { + //}; + // + //template + //struct B > { + // const A& obj; + // B(const A& o) : obj(o) {} + //}; + public void testBug368611_templatePartialSpecialization() throws Exception { + CharSequence[] code = getContents(2); + loadcode(code[0].toString()); + loadcode(code[1].toString()); + runOnProject(); + checkNoErrors(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java index 156d1e97c51..c64e96b3069 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java @@ -53,7 +53,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public AST2CPPSpecTest(String name) { super(name); } - + public static TestSuite suite() { return suite(AST2CPPSpecTest.class); } @@ -121,7 +121,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // C& operator=(const C& x) { s = x.s; return *this; } // ~C() { } // }; - // + // public void test3_1s4b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -141,10 +141,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // X::X(int = 0) { } // class D: public X { }; // D d2; // X(int) called by D() - public void test3_2s5_a() throws Exception { + public void test3_2s5_a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // // translation unit 2: // struct X { // X(int); @@ -154,7 +154,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // class D: public X { }; // X(int, int) called by D(); // // D()'s implicit definition // // violates the ODR - public void test3_2s5_b() throws Exception { + public void test3_2s5_b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -291,7 +291,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test3_4_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } - + // namespace NS { // class T { }; // void f(T); @@ -391,8 +391,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // // resolution chooses Z::h(double) // } public void test3_4_3_2s2() throws Exception { - String[] problems= {"AB::x", "x", "AB::i", "i"}; - parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4 + String[] problems= {"AB::x", "x", "AB::i", "i"}; + parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4 } // namespace A { @@ -423,7 +423,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // { // BD::a++; //OK: S is { A::a, A::a } // } - public void test3_4_3_2s3() throws Exception { + public void test3_4_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -506,7 +506,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // // cannot introduce a qualified type (7.1.5.3) // friend struct Glob; // OK: Refers to (as yet) undeclared Glob // // at global scope. - // + // // }; // struct Base { // struct Data; // OK: Declares nested Data @@ -524,7 +524,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // struct Base::Datum; // error: Datum undefined // struct Base::Data* pBase; // OK: refers to nested Data public void test3_4_4s3() throws Exception { - String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"}; + String[] problems= {"::Glob", "Glob", "Base::Datum", "Datum"}; parse(getAboveComment(), ParserLanguage.CPP, problems); } @@ -687,7 +687,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // arrpp++; //OK: sizeof UNKA* is known // } // struct X { - // int i; + // int i; // }; // now X is a complete type // int arr[10]; // now the type of arr is complete // X x; @@ -756,7 +756,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - // class D { // ... + // class D { // ... // }; // D d1; // const D d2; @@ -799,7 +799,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { IASTExpression expr= getExpressionOfStatement(fdef, 0); assertInstance(expr, ICPPASTNewExpression.class); ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr; - + assertNull(newExpr.getNewPlacement()); assertNull(newExpr.getNewInitializer()); IASTTypeId typeid= newExpr.getTypeId(); @@ -815,7 +815,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // }; public void test5_3_4s12() throws Exception { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856 - + IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0); IASTFunctionDefinition fdef= getDeclaration(tu, 1); @@ -826,7 +826,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertNull(newExpr.getNewPlacement()); assertNull(newExpr.getNewInitializer()); isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int"); - + // new(2,f) T; expr= getExpressionOfStatement(fdef, 1); assertInstance(expr, ICPPASTNewExpression.class); @@ -920,7 +920,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int x=0; // if (x) // int i; - // + // // if (x) { // int i; // } @@ -937,7 +937,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int x; // illformed,redeclaration of x // } // } - public void test6_4s3() throws Exception { + public void test6_4s3() throws Exception { // raised bug 90618 // gcc does not report an error, either, so leave it as it is. parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -962,7 +962,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // ~A() { } // operator bool() { return val != 0; } // }; - // + // // int foo() { // int i = 1; // while (A a = i) { @@ -997,7 +997,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // goto ly; // OK, jump implies destructor // // call for a followed by construction // // again immediately following label ly - // } + // } public void test6_7s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -1077,13 +1077,20 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } + // thread_local int e; + // static thread_local int f; + // extern thread_local int g; + public void test7_1_1s1() throws Exception { + parse(getAboveComment(), ParserLanguage.CPP, true, 0); + } + // static char* f(); // f() has internal linkage // char* f() // f() still has internal linkage // { // // } // char* g(); // g() has external linkage // static char* g() // error: inconsistent linkage - // { // + // { // // } // void h(); // inline void h(); // external linkage @@ -1138,12 +1145,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // typedef int I; // typedef int I; // typedef I I; - public void test7_1_3s2() throws Exception { + public void test7_1_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - // class complex { // + // class complex { // // }; // typedef int complex; // error: redefinition public void test7_1_3s3a() throws Exception { @@ -1151,7 +1158,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { } // typedef int complex; - // class complex { // + // class complex { // // }; // error: redefinition public void test7_1_3s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -1184,6 +1191,24 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertInstance(d, IASTProblemDeclaration.class); } + // constexpr int square(int x); + // constexpr int bufsz = 1024; + // struct pixel { + // int x; + // int y; + // constexpr pixel(int); + // }; + // constexpr pixel::pixel(int a) + // : x(square(a)), y(square(a)) + // { } + // constexpr int square(int x) { + // return x * x; + // } + // constexpr pixel large(4); + public void test7_1_5s1() throws Exception { + parse(getAboveComment(), ParserLanguage.CPP, true, 0); + } + // int foo() { // const int ci = 3; // cvqualified (initialized as required) // ci = 4; // illformed: attempt to modify const @@ -1212,7 +1237,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // X x; // Y(); // }; - // + // // int foo() { // const Y y; // y.x.i++; //wellformed: mutable member can be modified @@ -1560,7 +1585,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // } public void test7_3_3s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); - } + } // struct A { int x(); }; // struct B : A { }; @@ -1822,10 +1847,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 1); CPPNameCollector col = new CPPNameCollector(); tu.accept(col); - + assertInstance(col.getName(4), ICPPASTTemplateId.class); assertInstance(((ICPPASTTemplateId)col.getName(4)).getTemplateArguments()[0], IASTTypeId.class); - + final IASTName S_int_1 = col.getName(7); assertInstance(S_int_1, ICPPASTTemplateId.class); assertInstance(((ICPPASTTemplateId)S_int_1).getTemplateArguments()[0], IASTExpression.class); @@ -1861,7 +1886,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test8_2s7a() throws Exception { // TODO raised bug 90633 final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 1); - + BindingAssertionHelper ba= new BindingAssertionHelper(code, true); IFunction f= ba.assertNonProblem("f", 1, IFunction.class); isTypeEqual(f.getType(), "void (int (*)(C))"); @@ -1896,7 +1921,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // const int ci = 10, *pc = &ci, *const cpc = pc, **ppc; // int i, *p, *const cp = &i; - // + // // int f() { // i = ci; // *cp = ci; @@ -1978,7 +2003,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int a; // }; // class Y; - // + // // void f() { // int X::* pmi = &X::a; // void (X::* pmf)(int) = &X::f; @@ -2314,7 +2339,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { } // char msg[] = "Syntax error on line %s"; - public void test8_5_2s1() throws Exception { + public void test8_5_2s1() throws Exception { // raised bug 90647 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2527,7 +2552,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int g() { return a++; } // }; // int s::f() const { return a; } - // + // // void k(s& x, const s& y) // { // x.f(); @@ -2540,8 +2565,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { final String code = getAboveComment(); IASTTranslationUnit tu= parse(code, ParserLanguage.CPP, problems); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - bh.assertNonProblem("g();", 1); - bh.assertProblem("g(); //error", 1); + bh.assertNonProblem("g();", 1); + bh.assertProblem("g(); //error", 1); } // class process { @@ -2588,7 +2613,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // p = "Jennifer"; // // ... // } - public void test9_5s2() throws Exception { + public void test9_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2733,7 +2758,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // class B : public L { }; // class C : public A, public B { void f(); }; // wellformed // class D : public A, public L { void f(); }; // wellformed - // + // public void test10_1s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3560,7 +3585,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(code, ParserLanguage.CPP, false, 0); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPFunction dtor= bh.assertNonProblem("~B() {", 2); - + ICPPFunction d= bh.assertNonProblem("~B(); //1", 2); assertSame(dtor, d); d= bh.assertNonProblem("~B(); //2", 2); @@ -3569,7 +3594,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertSame(dtor, d); d= bh.assertNonProblem("~B(); //4", 2); assertSame(dtor, d); - + bh.assertProblem("~B_alias(); //5", 8); } @@ -3910,7 +3935,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // void h(int (*)()); // redeclaration of h(int()) // void h(int x()) { } // definition of h(int()) // void h(int (*x)()) { } // illformed: redefinition of h(int()) - public void test12_8s3d() throws Exception { + public void test12_8s3d() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4456,7 +4481,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // // ... // }; // Array v1(20); - // typedef complex dcomplex; + // typedef complex dcomplex; // Array v2(30); // Array v3(40); // void bar() { @@ -4659,7 +4684,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // static T s; // }; // template T X::s = 0; - public void test14_5_1_3s1() throws Exception { + public void test14_5_1_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4675,7 +4700,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template friend class frd; // // ... // }; - public void test14_5_4s1() throws Exception { + public void test14_5_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4773,7 +4798,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template class A { }; // #3 // template class A { }; // #4 // template class A { }; // #5 - // A a5; // ambiguous: matches #3 and #5 : expect problem + // A a5; // ambiguous: matches #3 and #5 : expect problem public void test14_5_5_1s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4824,12 +4849,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - // // file1.c + // // file1.c // template // void f(T*); - // void g(int* p) { - // f(p); // call - // // f(int*) + // void g(int* p) { + // f(p); // call + // // f(int*) // } public void test14_5_6_1s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -4891,7 +4916,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { ICPPSpecialization templateSpecialization = (ICPPSpecialization) inst.getTemplateDefinition(); assertSame(op1, templateSpecialization.getSpecializedBinding()); } - + // template struct A { A(); }; // template void f(T); // template void f(T*); @@ -5097,7 +5122,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template void N::B::f(C) { // C b; // C is the template parameter, not N::C // } - public void test14_6_1s6() throws Exception { + public void test14_6_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5139,7 +5164,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template struct X : B { // A a; // a has type double // }; - public void test14_6_2s3() throws Exception { + public void test14_6_2s3() throws Exception { final String content= getAboveComment(); IASTTranslationUnit tu= parse(content, ParserLanguage.CPP, true, 0); BindingAssertionHelper bh= new BindingAssertionHelper(content, true); @@ -5218,7 +5243,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template T X::s = 0; // X aa; // X bb; - public void test14_7s6() throws Exception { + public void test14_7s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5312,7 +5337,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // int i = m.get("Nicholas"); // // ... // } - public void test14_7_1s10() throws Exception { + public void test14_7_1s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5385,7 +5410,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // template class Array { }; // template void sort(Array& v) { } // template<> void sort(Array&) ; - public void test14_7_3s1() throws Exception { + public void test14_7_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5669,7 +5694,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f()", -2); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // struct X { }; // struct Y { // Y(X){} @@ -5680,8 +5705,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2 public void test14_8_2s8a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); - } - + } + // template int f(T[5]); // int I = f(0); // int j = f(0); // invalid array // also no error with gcc @@ -5750,7 +5775,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { BindingAssertionHelper bh= new BindingAssertionHelper(code, true); bh.assertProblem("f", 0); } - + // template int f(int); // int i2 = f(0); // can't conv 1 to int* public void test14_8_2s8g() throws Exception { @@ -5778,14 +5803,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_1s1a() throws Exception { final String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - + ICPPTemplateInstance inst; inst= bh.assertNonProblem("f({1,2,3})", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); bh.assertProblem("f({1,\"asdf\"})", 1); bh.assertProblem("g({1,2,3})", 1); } - + // template void f(Types& ...); // template void g(T1, Types ...); // void h(int x, float& y) { @@ -5796,14 +5821,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_1s1b() throws Exception { final String code= getAboveComment(); BindingAssertionHelper bh= new BindingAssertionHelper(code, true); - + ICPPTemplateInstance inst; inst= bh.assertNonProblem("f(x, y, z)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); inst= bh.assertNonProblem("g(x, y, z)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // template int f(T&&); // template int g(const T&&); // int i; @@ -5835,7 +5860,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f(g)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // // Ambiguous deduction causes the second function parameter to be a // // non-deduced context. // template int f(T, T (*p)(T)); @@ -5863,7 +5888,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f(1, g)", 1); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // struct A { // template operator T***(); // }; @@ -5874,7 +5899,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_3s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template T f(int); // #1 // template T f(U); // #2 // void g() { @@ -5883,7 +5908,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_4s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template struct Tuple { }; // template void g(Tuple); // #1 // template void g(Tuple); // #2 @@ -5892,17 +5917,17 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { // g(Tuple<>()); // calls #1 // g(Tuple()); // calls #2 // g(Tuple()); // calls #3 - // g(Tuple()); // calls #3 + // g(Tuple()); // calls #3 // } public void test14_8_2_4s12() throws Exception { final String code= getAboveComment(); parse(code, ParserLanguage.CPP, true, 0); - + BindingAssertionHelper bh= new BindingAssertionHelper(code, true); ICPPFunction g1= bh.assertNonProblem("g(Tuple)", 1); ICPPFunction g2= bh.assertNonProblem("g(Tuple)", 1); ICPPFunction g3= bh.assertNonProblem("g(Tuple)", 1); - + ICPPTemplateInstance x= bh.assertNonProblem("g(Tuple<>())", 1); assertSame(g1, x.getTemplateDefinition()); x= bh.assertNonProblem("g(Tuple())", 1); @@ -5911,8 +5936,8 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { assertSame(g3, x.getTemplateDefinition()); x= bh.assertNonProblem("g(Tuple())", 1); assertSame(g3, x.getTemplateDefinition()); - } - + } + // template void g(T); // void test() { // g({1,2,3}); // error: no argument deduced for T @@ -5981,7 +6006,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { public void test14_8_2_5s7d() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template void f(T&&); // template <> void f(int&) { } // #1 // template <> void f(int&&) { } // #2 @@ -6058,7 +6083,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f(a1, a2)", 1); assertEquals("<1>", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // template class A { // public: // typedef int X; @@ -6082,7 +6107,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } - + // template class A {}; // template void f(A); // void k1() { @@ -6144,7 +6169,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest { inst= bh.assertNonProblem("f()", -2); assertEquals("", ASTTypeUtil.getArgumentListString(inst.getTemplateArguments(), true)); } - + // template