Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2005-04-22 15:32:12 +0000
committerAndrew Niefer2005-04-22 15:32:12 +0000
commit7d7fa374bfd169ce8924a5c15bd01444e6e6e445 (patch)
tree3b28561e15cac305a67db6f44954d21fe7f25f32
parent365b5f320c58fd6d81910927179116c03e4a2e63 (diff)
downloadorg.eclipse.cdt-7d7fa374bfd169ce8924a5c15bd01444e6e6e445.tar.gz
org.eclipse.cdt-7d7fa374bfd169ce8924a5c15bd01444e6e6e445.tar.xz
org.eclipse.cdt-7d7fa374bfd169ce8924a5c15bd01444e6e6e445.zip
Templates.
- better handling of specializations - argument deduction, ranking of specializations and overloaded function templates - this fixes or addresses part of bugs 90682, 90684, 90668, 90686, 90672, 90678
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java552
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java1269
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java8
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java178
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java37
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java475
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateSpecialization.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java58
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java280
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunctionInstance.java247
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldInstance.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java82
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java58
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java24
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterInstance.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java211
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java197
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java116
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java240
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java56
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java837
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java83
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java16
44 files changed, 4073 insertions, 1273 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java
index 704c035a557..2c6fb3f2dc8 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java
@@ -35,7 +35,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("#define arraycheck(a,b) a[b] || b[a]\n"); //$NON-NLS-1$
try {
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -82,7 +82,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// D()’s implicit definition\n"); //$NON-NLS-1$
buffer.append("// violates the ODR\n"); //$NON-NLS-1$
try{
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -131,7 +131,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("typedef I I; // error, even though no reordering involved\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -164,7 +164,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("friend void A::f2(BT); // parameter type is B::BT\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -195,7 +195,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// equivalent to: ::X C::arr[C::number];\n"); //$NON-NLS-1$
buffer.append("// not to: C::X C::arr[C::number];\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -224,7 +224,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -263,7 +263,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("extern int h;\n"); //$NON-NLS-1$
buffer.append("T(g)(h,2); //declaration\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -328,7 +328,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("struct x x1; // x1 has class type B::x\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -357,7 +357,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("new (int(*[x])); // new typeid\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -382,7 +382,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("S<int()> x; // typeid\n"); //$NON-NLS-1$
buffer.append("S<int(1)> y; // expression (illformed)\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -411,7 +411,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f(g); //OK\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -432,7 +432,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("int b = f(a);\n"); //$NON-NLS-1$
buffer.append("int c(b);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -447,7 +447,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("char msg[] = \"Syntax error on line %s\n\";\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -488,7 +488,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("ra[1] = i; // modifies a[1]\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -517,7 +517,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -546,7 +546,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// no ambiguity because U::i is static\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -575,7 +575,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("return *this;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -622,7 +622,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("{ }\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -655,36 +655,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("(int (*)(int))&f; // cast expression as selector\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.1-8):
- template<int *a> struct R { };
- template<int b[5]> struct S { };
- int *p;
- R<p> w; // OK
- S<p> x; // OK due to parameter adjustment
- int v[5];
- R<v> y; // OK due to implicit argument conversion
- S<v> z; // OK due to both adjustment and conversion
- --End Example]
- */
- public void test14_1s8() { // TODO raised bug 90668
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<int *a> struct R { };\n"); //$NON-NLS-1$
- buffer.append("template<int b[5]> struct S { };\n"); //$NON-NLS-1$
- buffer.append("int *p;\n"); //$NON-NLS-1$
- buffer.append("R<p> w; // OK\n"); //$NON-NLS-1$
- buffer.append("S<p> x; // OK due to parameter adjustment\n"); //$NON-NLS-1$
- buffer.append("int v[5];\n"); //$NON-NLS-1$
- buffer.append("R<v> y; // OK due to implicit argument conversion\n"); //$NON-NLS-1$
- buffer.append("S<v> z; // OK due to both adjustment and conversion\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -701,7 +672,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template<class T, T* p, class U = T> class X { };\n"); //$NON-NLS-1$
buffer.append("template<class T> void f(T* p = new T);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -726,34 +697,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f<int()>(); // int() is a typeid:call the first f()\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.3-5):
- template<class T> struct A {
- ~A();
- };
- void f(A<int>* p, A<int>* q) {
- p->A<int>::~A(); // OK: destructor call
- q->A<int>::~A<int>(); // OK: destructor call
- }
- --End Example]
- */
- public void test14_3s5() { // TODO raised bug 90672
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> struct A {\n"); //$NON-NLS-1$
- buffer.append("~A();\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("void f(A<int>* p, A<int>* q) {\n"); //$NON-NLS-1$
- buffer.append("p->A<int>::~A(); // OK: destructor call\n"); //$NON-NLS-1$
- buffer.append("q->A<int>::~A<int>(); // OK: destructor call\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -794,13 +738,48 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template<void (*pf)(int)> struct A { };\n"); //$NON-NLS-1$
buffer.append("A<&f> a; // selects f(int)\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
}
/**
+ [--Start Example(CPP 14.5.2-2):
+ template <class T> struct A {
+ void f(int);
+ template <class T2> void f(T2);
+ };
+ template <> void A<int>::f(int) { } // nontemplate member
+ template <> template <> void A<int>::f<>(int) { } // template member
+ int main()
+ {
+ A<char> ac;
+ ac.f(1); //nontemplate
+ ac.f('c'); //template
+ ac.f<>(1); //template
+ }
+ --End Example]
+ */
+ public void test14_5_2s2() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template <class T> struct A {\n"); //$NON-NLS-1$
+ buffer.append("void f(int);\n"); //$NON-NLS-1$
+ buffer.append("template <class T2> void f(T2);\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("template <> void A<int>::f(int) { } // nontemplate member\n"); //$NON-NLS-1$
+ buffer.append("template <> template <> void A<int>::f<>(int) { } // template member\n"); //$NON-NLS-1$
+ buffer.append("int main()\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("A<char> ac;\n"); //$NON-NLS-1$
+ buffer.append("ac.f(1); //nontemplate\n"); //$NON-NLS-1$
+ buffer.append("ac.f('c'); //template\n"); //$NON-NLS-1$
+ buffer.append("ac.f<>(1); //template\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 2); //should be 0
+ }
+
+ /**
[--Start Example(CPP 14.5.3-1):
template<class T> class task;
template<class T> task<T>* preempt(task<T>*);
@@ -831,67 +810,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.5.3-6):
- template<class T> struct A {
- struct B { };
- void f();
- };
- class C {
- template<class T> friend struct A<T>::B;
- template<class T> friend void A<T>::f();
- };
- --End Example]
- */
- public void test14_5_3s6() { // TODO raised bug 90678
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> struct A {\n"); //$NON-NLS-1$
- buffer.append("struct B { };\n"); //$NON-NLS-1$
- buffer.append("void f();\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("class C {\n"); //$NON-NLS-1$
- buffer.append("template<class T> friend struct A<T>::B;\n"); //$NON-NLS-1$
- buffer.append("template<class T> friend void A<T>::f();\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.5.4-6):
- template<class T> struct A {
- class C {
- template<class T2> struct B { };
- };
- };
- // partial specialization of A<T>::C::B<T2>
- template<class T> template<class T2>
- struct A<T>::C::B<T2*> { };
- A<short>::C::B<int*> absip; // uses partial specialization
- --End Example]
- */
- public void test14_5_4s6() { // TODO raised bug 90678
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> struct A {\n"); //$NON-NLS-1$
- buffer.append("class C {\n"); //$NON-NLS-1$
- buffer.append("template<class T2> struct B { };\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("// partial specialization of A<T>::C::B<T2>\n"); //$NON-NLS-1$
- buffer.append("template<class T> template<class T2>\n"); //$NON-NLS-1$
- buffer.append("struct A<T>::C::B<T2*> { };\n"); //$NON-NLS-1$
- buffer.append("A<short>::C::B<int*> absip; // uses partial specialization\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -922,13 +841,32 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("A<int,int*> a; // uses the partial specialization, which is found through\n"); //$NON-NLS-1$
buffer.append("// the using declaration which refers to the primary template\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
}
/**
+ [--Start Example(CPP 14.5.4.2-2):
+ template<int I, int J, class T> class X { };
+ template<int I, int J> class X<I, J, int> { }; // #1
+ template<int I> class X<I, I, int> { }; // #2
+ template<int I, int J> void f(X<I, J, int>); // #A
+ template<int I> void f(X<I, I, int>); // #B
+ --End Example]
+ */
+ public void test14_5_4_2s2() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<int I, int J, class T> class X { };\n"); //$NON-NLS-1$
+ buffer.append("template<int I, int J> class X<I, J, int> { }; // #1\n"); //$NON-NLS-1$
+ buffer.append("template<int I> class X<I, I, int> { }; // #2\n"); //$NON-NLS-1$
+ buffer.append("template<int I, int J> void f(X<I, J, int>); // #A\n"); //$NON-NLS-1$
+ buffer.append("template<int I> void f(X<I, I, int>); // #B\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 2);
+ }
+
+ /**
[--Start Example(CPP 14.5.4.3-2):
template<class T> struct A {
template<class T2> struct B {}; // #1
@@ -951,48 +889,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("A<short>::B<int*> absip; // uses #3\n"); //$NON-NLS-1$
buffer.append("A<char>::B<int> abci; // uses #1\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.5.5.1-1):
- // file1.c
- template<class T>
- void f(T*);
- void g(int* p) {
- f(p); // call
- // f<int>(int*)
- }
- // file2.c
- template<class T>
- void f(T);
- void h(int* p) {
- f(p); // call
- // f<int*>(int*)
- }
- --End Example]
- */
- public void test14_5_5_1s1() { // TODO raised bug 90682
- StringBuffer buffer = new StringBuffer();
- buffer.append("// file1.c \n"); //$NON-NLS-1$
- buffer.append("template<class T>\n"); //$NON-NLS-1$
- buffer.append("void f(T*);\n"); //$NON-NLS-1$
- buffer.append("void g(int* p) { \n"); //$NON-NLS-1$
- buffer.append("f(p); // call \n"); //$NON-NLS-1$
- buffer.append("// f<int>(int*) \n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- buffer.append("// file2.c\n"); //$NON-NLS-1$
- buffer.append("template<class T>\n"); //$NON-NLS-1$
- buffer.append("void f(T);\n"); //$NON-NLS-1$
- buffer.append("void h(int* p) {\n"); //$NON-NLS-1$
- buffer.append("f(p); // call\n"); //$NON-NLS-1$
- buffer.append("// f<int*>(int*)\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1011,7 +908,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template <int K, int L> A<K+L> f(A<K>, A<L>); // same as #1\n"); //$NON-NLS-1$
buffer.append("template <int I, int J> A<IJ> f(A<I>, A<J>); // different from #1\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1028,61 +925,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template <int I, int J> void f(A<I+J>); // #1\n"); //$NON-NLS-1$
buffer.append("template <int K, int L> void f(A<K+L>); // same as #1\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.5.5.2-6):
- 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;
- f(ip); //calls #2
- g(ip); //calls #4
- }
- --End Example]
- */
- public void test14_5_5_2s6() { // TODO raised bug 90684
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> void f(T); // #1\n"); //$NON-NLS-1$
- buffer.append("template<class T> void f(T*, int=1); // #2\n"); //$NON-NLS-1$
- buffer.append("template<class T> void g(T); // #3\n"); //$NON-NLS-1$
- buffer.append("template<class T> void g(T*, ...); // #4\n"); //$NON-NLS-1$
- buffer.append("int main() {\n"); //$NON-NLS-1$
- buffer.append("int* ip;\n"); //$NON-NLS-1$
- buffer.append("f(ip); //calls #2\n"); //$NON-NLS-1$
- buffer.append("g(ip); //calls #4\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.6.1-1):
- template<class T> class X {
- X* p; // meaning X<T>
- X<T>* p2;
- X<int>* p3;
- };
- --End Example]
- */
- public void test14_6_1s1() { // TODO can not reproduce IProblemBinding via DOMAST View
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> class X {\n"); //$NON-NLS-1$
- buffer.append("X* p; // meaning X<T>\n"); //$NON-NLS-1$
- buffer.append("X<T>* p2;\n"); //$NON-NLS-1$
- buffer.append("X<int>* p3;\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1099,7 +942,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template<class T, T* p, class U = T> class X { };\n"); //$NON-NLS-1$
buffer.append("template<class T> void f(T* p = new T);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1121,7 +964,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
public void test14_6_1s6() { // TODO raised bug 90686
StringBuffer buffer = new StringBuffer();
buffer.append("namespace N {\n"); //$NON-NLS-1$
- buffer.append("class C { };\n"); //$NON-NLS-1$
+ buffer.append("int C;\n"); //$NON-NLS-1$
buffer.append("template<class T> class B {\n"); //$NON-NLS-1$
buffer.append("void f(T);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
@@ -1130,7 +973,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("C b; // C is the template parameter, not N::C\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1157,13 +1000,50 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("A a; // a has type double\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
}
/**
+ [--Start Example(CPP 14.7-3):
+ template<class T = int> struct A {
+ static int x;
+ };
+ template<class U> void g(U) { }
+ template<> struct A<double> { }; // specialize for T == double
+ template<> struct A<> { }; // specialize for T == int
+ template<> void g(char) { } // specialize for U == char
+ // U is deduced from the parameter type
+ template<> void g<int>(int) { } // specialize for U == int
+ template<> int A<char>::x = 0; // specialize for T == char
+ template<class T = int> struct B {
+ static int x;
+ };
+ template<> int B<>::x = 1; // specialize for T == int
+ --End Example]
+ */
+ public void test14_7s3() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T = int> struct A {\n"); //$NON-NLS-1$
+ buffer.append("static int x;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("template<class U> void g(U) { }\n"); //$NON-NLS-1$
+ buffer.append("template<> struct A<double> { }; // specialize for T == double\n"); //$NON-NLS-1$
+ buffer.append("template<> struct A<> { }; // specialize for T == int\n"); //$NON-NLS-1$
+ buffer.append("template<> void g(char) { } // specialize for U == char\n"); //$NON-NLS-1$
+ buffer.append("// U is deduced from the parameter type\n"); //$NON-NLS-1$
+ buffer.append("template<> void g<int>(int) { } // specialize for U == int\n"); //$NON-NLS-1$
+ buffer.append("template<> int A<char>::x = 0; // specialize for T == char\n"); //$NON-NLS-1$
+ buffer.append("template<class T = int> struct B {\n"); //$NON-NLS-1$
+ buffer.append("static int x;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("template<> int B<>::x = 1; // specialize for T == int\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 2);
+ }
+
+ /**
[--Start Example(CPP 14.7.1-5):
template <class T> struct S {
operator int();
@@ -1190,37 +1070,39 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// instantiation of S<float> allowed but not required\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
}
/**
- [--Start Example(CPP 14.7.1-14):
- template<class T> class X {
- X<T>* p; // OK
- X<T*> a; // implicit generation of X<T> requires
- // the implicit instantiation of X<T*> which requires
- // the implicit instantiation of X<T**> which ...
- };
+ [--Start Example(CPP 14.7.2-2):
+ template<class T> class Array { void mf(); };
+ template class Array<char>;
+ template void Array<int>::mf();
+ template<class T> void sort(Array<T>& v) { }
+ template void sort(Array<char>&); // argument is deduced here
+ namespace N {
+ template<class T> void f(T&) { }
+ }
+ template void N::f<int>(int&);
--End Example]
*/
- public void test14_7_1s14() { // TODO can't reproduce via DOMAST View
+ public void test14_7_2s2() throws Exception {
StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> class X {\n"); //$NON-NLS-1$
- buffer.append("X<T>* p; // OK\n"); //$NON-NLS-1$
- buffer.append("X<T*> a; // implicit generation of X<T> requires\n"); //$NON-NLS-1$
- buffer.append("// the implicit instantiation of X<T*> which requires\n"); //$NON-NLS-1$
- buffer.append("// the implicit instantiation of X<T**> which ...\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
+ buffer.append("template<class T> class Array { void mf(); };\n"); //$NON-NLS-1$
+ buffer.append("template class Array<char>;\n"); //$NON-NLS-1$
+ buffer.append("template void Array<int>::mf();\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void sort(Array<T>& v) { }\n"); //$NON-NLS-1$
+ buffer.append("template void sort(Array<char>&); // argument is deduced here\n"); //$NON-NLS-1$
+ buffer.append("namespace N {\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void f(T&) { }\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ buffer.append("template void N::f<int>(int&);\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 2);
}
-
+
/**
[--Start Example(CPP 14.7.2-6):
template<class T> class Array { };
@@ -1236,7 +1118,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// instantiate sort(Array<int>&) - templateargument deduced\n"); //$NON-NLS-1$
buffer.append("template void sort<>(Array<int>&);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1259,33 +1141,32 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template<class T> void sort(Array<T>& v) { }\n"); //$NON-NLS-1$
buffer.append("template<> void sort<char*>(Array<char*>&) ;\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
}
+
/**
- [--Start Example(CPP 14.7.3-14):
- 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
+ [--Start Example(CPP 14.7.3-11):
+ template<class T> class Array { };
+ template<class T> void sort(Array<T>& v);
+ // explicit specialization for sort(Array<int>&)
+ // with deduces templateargument of type int
+ template<> void sort(Array<int>&);
--End Example]
*/
- public void test14_7_3s14() { // TODO similar bug already
+ public void test14_7_3s11() throws Exception {
StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> void f(T) { }\n"); //$NON-NLS-1$
- buffer.append("template<class T> inline T g(T) { }\n"); //$NON-NLS-1$
- buffer.append("template<> inline void f<>(int) { } // OK: inline\n"); //$NON-NLS-1$
- buffer.append("template<> int g<>(int) { } // OK: not inline\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
+ buffer.append("template<class T> class Array { };\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void sort(Array<T>& v);\n"); //$NON-NLS-1$
+ buffer.append("// explicit specialization for sort(Array<int>&)\n"); //$NON-NLS-1$
+ buffer.append("// with deduces templateargument of type int\n"); //$NON-NLS-1$
+ buffer.append("template<> void sort(Array<int>&);\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 1);
}
-
+
/**
[--Start Example(CPP 14.7.3-16):
template<class T> struct A {
@@ -1329,7 +1210,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// member specialization even if defined in class definition\n"); //$NON-NLS-1$
buffer.append("template<> void A<int>::h(int) { }\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1356,40 +1237,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template<> template<> A<int>::B<double> { };\n"); //$NON-NLS-1$
buffer.append("template<> template<> void A<char>::B<char>::mf() { };\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.8-2):
- template<class T> void f(T* p)
- {
- static T s;
- // ...
- };
- void g(int a, char* b)
- {
- f(&a); //call f<int>(int*)
- f(&b); //call f<char*>(char**)
- }
- --End Example]
- */
- public void test14_8s2() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> void f(T* p)\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("static T s;\n"); //$NON-NLS-1$
- buffer.append("// ...\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("void g(int a, char* b)\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("f(&a); //call f<int>(int*)\n"); //$NON-NLS-1$
- buffer.append("f(&b); //call f<char*>(char**)\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1406,7 +1254,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template <class T> int f(typename T::B*);\n"); //$NON-NLS-1$
buffer.append("int i = f<int>(0);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1429,7 +1277,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("int i = f<A>(0);\n"); //$NON-NLS-1$
buffer.append("int j = f<C>(0);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1474,7 +1322,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("h<const int>(1,0);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1499,7 +1347,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f(p); // f(const int *)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1534,7 +1382,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f(d2); //calls f(B<int>&)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1561,7 +1409,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f(ab); //calls f(A<B>)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1590,30 +1438,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f(di); // f( (B<int>&)di )\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
- /**
- [--Start Example(CPP 14.8.3-6):
- template<class T> void f(T); // declaration
- void g()
- {
- f("Annemarie"); // call of f<const char*>
- }
- --End Example]
- */
- public void test14_8_3s6() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> void f(T); // declaration\n"); //$NON-NLS-1$
- buffer.append("void g()\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("f(\"Annemarie\"); // call of f<const char*>\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1638,7 +1463,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template <int I> void f(A<I>, A<I+10>);\n"); //$NON-NLS-1$
buffer.append("template <int I> void f(A<I>, A<I+11>);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1657,13 +1482,40 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("template <int I> void f(A<I>, A<I+10>);\n"); //$NON-NLS-1$
buffer.append("template <int I> void f(A<I>, A<I+1+2+3+4>);\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
assertTrue(false);
} catch (Exception e) {
}
}
/**
+ [--Start Example(CPP 14.8.1-4):
+ template<class T> void f(T);
+ class Complex {
+ // ...
+ Complex(double);
+ };
+ void g()
+ {
+ f<Complex>(1); // OK, means f<Complex>(Complex(1))
+ }
+ --End Example]
+ */
+ public void test14_8_1s4() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T);\n"); //$NON-NLS-1$
+ buffer.append("class Complex {\n"); //$NON-NLS-1$
+ buffer.append("// ...\n"); //$NON-NLS-1$
+ buffer.append("Complex(double);\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("void g()\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("f<Complex>(1); // OK, means f<Complex>(Complex(1))\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 1);
+ }
+
+ /**
[--Start Example(CPP 14.8.2.4-14):
template<int i, typename T>
T deduce(typename A<T>::X x, // T is not deduced here
@@ -1692,7 +1544,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("// i is explicitly specified to be 77, y.ym must be convertible\n"); //$NON-NLS-1$
buffer.append("// to B<77>::Y\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
@@ -1723,7 +1575,7 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
buffer.append("f(i,i); //#2: f<int>(i,char(i))\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
assertTrue(false);
} catch (Exception e) {
}
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 a0b949d83d9..b95477aa51f 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
@@ -11,7 +11,6 @@
package org.eclipse.cdt.core.parser.tests.ast2;
import org.eclipse.cdt.core.parser.ParserLanguage;
-import org.eclipse.cdt.internal.core.parser.ParserException;
/**
* @author dsteffle
@@ -46,7 +45,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test2_4s5() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int x=x+++++y;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -57,7 +56,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test2_13_1s1() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int a=12, b=014, c=0XC;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -110,7 +109,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int Int; // declares Int\n"); //$NON-NLS-1$
buffer.append("extern X anotherX; // declares anotherX\n"); //$NON-NLS-1$
buffer.append("using N::d; // declares N::d\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -137,7 +136,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("C b = a;\n"); //$NON-NLS-1$
buffer.append("b = a;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -161,7 +160,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("~C() { }\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -176,7 +175,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct X; // declare X as a struct type\n"); //$NON-NLS-1$
buffer.append("struct X* x1; // use X in pointer formation\n"); //$NON-NLS-1$
buffer.append("X* x2; // use X in pointer formation\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -197,7 +196,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i = j, j;\n"); //$NON-NLS-1$
buffer.append("j = 42;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -214,7 +213,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int x = 12;\n"); //$NON-NLS-1$
buffer.append("{ int x = x; }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -231,7 +230,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const int i = 2;\n"); //$NON-NLS-1$
buffer.append("{ int i[i]; }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -248,7 +247,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const int x = 12;\n"); //$NON-NLS-1$
buffer.append("{ enum { x = x }; }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -301,7 +300,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("int q(); // error: different return type\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -336,7 +335,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// 3) scope of namespace A\n"); //$NON-NLS-1$
buffer.append("// 4) global scope, before the definition of A::N::f\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -351,7 +350,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("namespace M {\n"); //$NON-NLS-1$
buffer.append("class B { };\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -396,7 +395,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// 4) scope of namespace M::N\n"); //$NON-NLS-1$
buffer.append("// 5) scope of namespace M\n"); //$NON-NLS-1$
buffer.append("// 6) global scope, before the definition of M::N::X::f\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -421,7 +420,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int main() {\n"); //$NON-NLS-1$
buffer.append("f(parm); //OK: calls NS::f\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -440,7 +439,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
*/
public void test3_4_3s1() throws Exception {
StringBuffer buffer = new StringBuffer();
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
@@ -491,7 +490,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("AB *p;\n"); //$NON-NLS-1$
buffer.append("p->AB::~AB(); // explicitly calls the destructor for A\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -598,7 +597,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// S is { Y::h(int), Z::h(double) } and overload\n"); //$NON-NLS-1$
buffer.append("// resolution chooses Z::h(double)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -664,7 +663,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("BD::a++; //OK: S is { A::a, A::a }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -707,7 +706,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A::b++; //OK: both A and B searched (once), S is { B::b }\n"); //$NON-NLS-1$
buffer.append("B::b++; //OK: b declared directly in B, S is { B::b }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -744,7 +743,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i = C::x; // OK, A::x (of type int)\n"); //$NON-NLS-1$
buffer.append("int j = C::y; // ambiguous, A::y or B::y\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -769,7 +768,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("void A::f1(int) { } // illformed,\n"); //$NON-NLS-1$
buffer.append("// f1 is not a member of A\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -804,7 +803,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("using namespace A;\n"); //$NON-NLS-1$
buffer.append("using namespace C::D;\n"); //$NON-NLS-1$
buffer.append("void B::f1(int){} // OK, defines A::B::f1(int)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -870,7 +869,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct Base::Data; // error: cannot introduce a qualified type (7.1.5.3)\n"); //$NON-NLS-1$
buffer.append("struct Base::Datum; // error: Datum undefined\n"); //$NON-NLS-1$
buffer.append("struct Base::Data* pBase; // OK: refers to nested Data\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -899,7 +898,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("extern int i; //3: external linkage\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -938,7 +937,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("void q() { //\n"); //$NON-NLS-1$
buffer.append("} // some other, unrelated q\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -961,7 +960,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef A B;\n"); //$NON-NLS-1$
buffer.append("extern B b; // illformed\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -974,7 +973,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("int main(int argc, char* argv[]) { //\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1023,7 +1022,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void* q = pb; // OK: pb points to valid memory\n"); //$NON-NLS-1$
buffer.append("pb->f(); //undefined behavior, lifetime of *pb has ended\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -1072,7 +1071,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("c1 = c2; // welldefined\n"); //$NON-NLS-1$
buffer.append("c1.f(); //welldefined; c1 refers to a new object of type C\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1097,7 +1096,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B b;\n"); //$NON-NLS-1$
buffer.append("new (&b) T;\n"); //$NON-NLS-1$
buffer.append("} //undefined behavior at block exit\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1124,7 +1123,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("b.~B();\n"); //$NON-NLS-1$
buffer.append("new (&b) const B; // undefined behavior\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1147,7 +1146,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// obj might be modified\n"); //$NON-NLS-1$
buffer.append("memcpy(&obj, buf, N); // at this point, each subobject of obj of scalar type\n"); //$NON-NLS-1$
buffer.append("// holds its original value\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -1166,7 +1165,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// provided that t2p points to an initialized object ...\n"); //$NON-NLS-1$
buffer.append("memcpy(t1p, t2p, sizeof(T)); // at this point, every subobject of POD type in *t1p contains\n"); //$NON-NLS-1$
buffer.append("// the same value as the corresponding subobject in *t2p\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -1219,7 +1218,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("xp++; //OK: X is complete\n"); //$NON-NLS-1$
buffer.append("arrp++; //illformed: UNKA can’t be completed\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1230,7 +1229,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test3_10s3() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int& f();\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1251,7 +1250,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("i = ++i + 1; // the behavior is unspecified\n"); //$NON-NLS-1$
buffer.append("i = i + 1; // the value of i is incremented\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -1272,7 +1271,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("B* bp = dynamic_cast<B*>(dp); // equivalent to B* bp = dp;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1333,7 +1332,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// cast from virtual base\n"); //$NON-NLS-1$
buffer.append("E* ep1 = dynamic_cast<E*>(ap); // succeeds\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1362,7 +1361,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typeid(D) == typeid(d2); // yields true\n"); //$NON-NLS-1$
buffer.append("typeid(D) == typeid(const D&); // yields true\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1385,7 +1384,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int foo() {\n"); //$NON-NLS-1$
buffer.append("static_cast<D&>(br); // produces lvalue to the original d object\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1404,7 +1403,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int foo() {\n"); //$NON-NLS-1$
buffer.append("&B::i; // has type int A::*\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1419,7 +1418,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int n=2;\n"); //$NON-NLS-1$
buffer.append("int x=new float[n][5];\n"); //$NON-NLS-1$
buffer.append("int y=new float[5][n];\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1444,7 +1443,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("return (A*)( p ); // illformed\n"); //$NON-NLS-1$
buffer.append("// static_cast interpretation\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1459,7 +1458,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int foo() {\n"); //$NON-NLS-1$
buffer.append("(ptr_to_obj->*ptr_to_mfct)(10);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -1486,7 +1485,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p <= q; // Both converted to const void * before comparison\n"); //$NON-NLS-1$
buffer.append("pi <= pci; // Both converted to const int *const * before comparison\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1519,7 +1518,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int (D::*pdl)() = pl;\n"); //$NON-NLS-1$
buffer.append("int (D::*pdr)() = pr;\n"); //$NON-NLS-1$
buffer.append("bool x = (pdl == pdr); // false\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1538,7 +1537,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int a=0, t=1, c=2;\n"); //$NON-NLS-1$
buffer.append("f(a, (t=3, t+2), c);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1565,7 +1564,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1592,7 +1591,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1629,7 +1628,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("i = 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1652,7 +1651,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("a[i] = i;\n"); //$NON-NLS-1$
buffer.append("int j = i; // j = 42\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1674,7 +1673,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
*/
public void test6_7s3() throws Exception {
StringBuffer buffer = new StringBuffer();
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1693,7 +1692,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("static int s = foo(2*i); // recursive call – undefined\n"); //$NON-NLS-1$
buffer.append("return i+1;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1720,7 +1719,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("T(f) = { 1, 2 }; // declaration\n"); //$NON-NLS-1$
buffer.append("T(*g)(double(3)); // declaration\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -1767,7 +1766,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// properly since it depends\n"); //$NON-NLS-1$
buffer.append("// on T2 being a typename\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1782,7 +1781,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef char* Pc;\n"); //$NON-NLS-1$
buffer.append("void f(const Pc); // void f(char* const) (not const char*)\n"); //$NON-NLS-1$
buffer.append("void g(const int Pc); // void g(const int)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1795,7 +1794,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("void h(unsigned Pc); // void h(unsigned int)\n"); //$NON-NLS-1$
buffer.append("void k(unsigned int Pc); // void k(unsigned int)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1852,7 +1851,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("static int c; // error: inconsistent linkage\n"); //$NON-NLS-1$
buffer.append("extern int d; // d has external linkage\n"); //$NON-NLS-1$
buffer.append("static int d; // error: inconsistent linkage\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1879,7 +1878,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("g(a); //error: S is incomplete\n"); //$NON-NLS-1$
buffer.append("f(); //error: S is incomplete\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1896,7 +1895,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("mutable const int* p; // OK\n"); //$NON-NLS-1$
buffer.append("mutable int* const q; // illformed\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1911,7 +1910,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int MILES, *KLICKSP;\n"); //$NON-NLS-1$
buffer.append("MILES distance;\n"); //$NON-NLS-1$
buffer.append("extern KLICKSP metricp;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1931,7 +1930,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int I;\n"); //$NON-NLS-1$
buffer.append("typedef I I;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
@@ -1947,7 +1946,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class complex { // \n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("typedef int complex; // error: redefinition\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1962,7 +1961,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int complex;\n"); //$NON-NLS-1$
buffer.append("class complex { // \n"); //$NON-NLS-1$
buffer.append("}; // error: redefinition\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1985,7 +1984,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef struct S T;\n"); //$NON-NLS-1$
buffer.append("S a = T(); // OK\n"); //$NON-NLS-1$
buffer.append("struct T * p; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -1996,7 +1995,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test7_1_3s5a() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("typedef struct { } *ps, S; // S is the class name for linkage purposes\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2013,7 +2012,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("S(); //error: requires a return type because S is\n"); //$NON-NLS-1$
buffer.append("// an ordinary member function, not a constructor\n"); //$NON-NLS-1$
buffer.append("} S;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2050,7 +2049,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int* iq = const_cast<int*>(ciq); // cast required\n"); //$NON-NLS-1$
buffer.append("*iq = 4; // undefined: modifies a const object\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2097,7 +2096,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p->x.i = 99; // wellformed: mutable member can be modified\n"); //$NON-NLS-1$
buffer.append("p->x.j = 99; // undefined: modifies a const member\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2110,7 +2109,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("enum { a, b, c=0 };\n"); //$NON-NLS-1$
buffer.append("enum { d, e, f=e+2 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2127,7 +2126,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const int x = 12;\n"); //$NON-NLS-1$
buffer.append("{ enum { x = x }; }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2150,7 +2149,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("if (*cp == blue) // ...\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2193,7 +2192,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(p->left); // OK\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -2218,7 +2217,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void g() { i++; } // Inner::i\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2257,7 +2256,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A::i++; // A::unique::i\n"); //$NON-NLS-1$
buffer.append("j++; // A::unique::j\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -2274,7 +2273,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f() { //\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2309,7 +2308,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("namespace R {\n"); //$NON-NLS-1$
buffer.append("void Q::V::g() { } // error: R doesn’t enclose Q\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2368,7 +2367,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A::X::f(x); //error: f is not a member of A::X\n"); //$NON-NLS-1$
buffer.append("A::X::Y::g(); // error: g is not a member of A::X::Y\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2385,7 +2384,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("namespace CWVLN = Company_with_very_long_name;\n"); //$NON-NLS-1$
buffer.append("namespace CWVLN = Company_with_very_long_name; // OK: duplicate\n"); //$NON-NLS-1$
buffer.append("namespace CWVLN = CWVLN;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2416,7 +2415,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f(int) { f('c'); } // calls B::f(char)\n"); //$NON-NLS-1$
buffer.append("void g(int) { g('c'); } // recursively calls D::g(int)\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2443,7 +2442,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("using B::x; // OK: x is a union member of base B\n"); //$NON-NLS-1$
buffer.append("using C::g; // error: C isn’t a base of D2\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -2472,7 +2471,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("using A::f<double>; // illformed\n"); //$NON-NLS-1$
buffer.append("using A::X<int>; // illformed\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2503,7 +2502,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("using X::s; // error: X::s is a class member\n"); //$NON-NLS-1$
buffer.append("// and this is not a member declaration.\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2538,7 +2537,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X::f(); //calls ::f\n"); //$NON-NLS-1$
buffer.append("X::g(); //calls A::g\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2587,7 +2586,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("using B::i;\n"); //$NON-NLS-1$
buffer.append("using B::i; // error: double member declaration\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2632,7 +2631,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// that is, for A::f(int) and A::f(char).\n"); //$NON-NLS-1$
buffer.append("f('a'); //calls f(char)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2677,7 +2676,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f(int); // error:\n"); //$NON-NLS-1$
buffer.append("// f(int) conflicts with C::f(int) and B::f(int)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -2728,7 +2727,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p->g(1); //calls B::g(int)\n"); //$NON-NLS-1$
buffer.append("p->g('a'); //calls D::g(char)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2765,7 +2764,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("return d>\n"); //$NON-NLS-1$
buffer.append("x(); // ambiguous: B::x or C::x\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -2800,7 +2799,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("public:\n"); //$NON-NLS-1$
buffer.append("using A::g; // B::g is a public synonym for A::g\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2859,7 +2858,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f4() {\n"); //$NON-NLS-1$
buffer.append("i = 5; // illformed; neither i is visible\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -2892,7 +2891,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("using namespace N;\n"); //$NON-NLS-1$
buffer.append("i = 7; // error: both M::i and N::i are visible\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -2941,7 +2940,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int n = j; // D::j hides B::j\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3000,7 +2999,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(1); //error: ambiguous: D::f(int) or E::f(int)?\n"); //$NON-NLS-1$
buffer.append("f('a'); //OK: D::f(char)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -3017,7 +3016,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("extern \"C\" {\n"); //$NON-NLS-1$
buffer.append("double sqrt(double); // C linkage\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -3048,7 +3047,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void (*pf2)(FUNC*); // the name of the variable pf2 has C++ linkage and\n"); //$NON-NLS-1$
buffer.append("// the type of pf2 is pointer to C++ function that\n"); //$NON-NLS-1$
buffer.append("// takes one parameter of type pointer to C function\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3097,7 +3096,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// C function\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3144,7 +3143,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// definition for the function h\n"); //$NON-NLS-1$
buffer.append("// with C language linkage\n"); //$NON-NLS-1$
buffer.append("// A::h and ::h refer to the same function\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3157,7 +3156,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("extern \"C\" double f();\n"); //$NON-NLS-1$
buffer.append("static double f(); // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3174,7 +3173,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("extern \"C\" {\n"); //$NON-NLS-1$
buffer.append("int i; // definition\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3185,7 +3184,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test7_5s7c() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("extern \"C\" static void f(); // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3206,7 +3205,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int (*p3i)[3];\n"); //$NON-NLS-1$
buffer.append("int *f();\n"); //$NON-NLS-1$
buffer.append("int (*pf)(double);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3235,7 +3234,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("S y((int)a); // object declaration\n"); //$NON-NLS-1$
buffer.append("S z = int(a); // object declaration\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3254,7 +3253,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("sizeof(int(1)); // expression\n"); //$NON-NLS-1$
buffer.append("// sizeof(int()); // typeid (illformed)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3273,7 +3272,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("(int(1)); //expression\n"); //$NON-NLS-1$
buffer.append("// (int())1; //typeid (illformed)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3288,7 +3287,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class C { };\n"); //$NON-NLS-1$
buffer.append("void h(int *(C[10])); // void h(int *(*_fp)(C _parm[10]));\n"); //$NON-NLS-1$
buffer.append("// not: void h(int *C[10]);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3311,7 +3310,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void A::B::f() { } // illformed: the declarator must not be\n"); //$NON-NLS-1$
buffer.append("// qualified with A::\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3322,7 +3321,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test8_3s4() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int unsigned i;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3353,7 +3352,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("pc = p;\n"); //$NON-NLS-1$
buffer.append("ppc = &pc;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3384,7 +3383,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p = pc; // error\n"); //$NON-NLS-1$
buffer.append("ppc = &p; // error\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3405,7 +3404,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("*ppc = &ci; // OK, but would make p point to ci ...\n"); //$NON-NLS-1$
buffer.append("*p = 5; // clobber ci\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3420,7 +3419,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int& A;\n"); //$NON-NLS-1$
buffer.append("const A aref = 3; // illformed;\n"); //$NON-NLS-1$
buffer.append("// nonconst reference initialized with rvalue\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3481,7 +3480,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("link* q = new link;\n"); //$NON-NLS-1$
buffer.append("h(q);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3528,7 +3527,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("(obj.*pmf)(7); //call a function member of obj\n"); //$NON-NLS-1$
buffer.append("// with the argument 7\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3543,7 +3542,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int A[5], AA[2][3];\n"); //$NON-NLS-1$
buffer.append("typedef const A CA; // type is ‘‘array of 5 const int’’\n"); //$NON-NLS-1$
buffer.append("typedef const AA CAA; // type is ‘‘array of 2 array of 3 const int’’\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3556,7 +3555,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("float fa[17], *afp[17];\n"); //$NON-NLS-1$
buffer.append("static int x3d[3][5][7];\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3567,7 +3566,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test8_3_4s8() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int x[3][5];\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3588,7 +3587,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("printf(\"hello world\");\n"); //$NON-NLS-1$
buffer.append("printf(\"a=%d b=%d\", a, b);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3607,7 +3606,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const F f; // illformed:\n"); //$NON-NLS-1$
buffer.append("// not equivalent to: void f() const;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3620,7 +3619,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("#define FILE int\n"); //$NON-NLS-1$
buffer.append("int fseek(FILE*, long, int);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3637,7 +3636,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("F fv; // OK: equivalent to void fv();\n"); //$NON-NLS-1$
buffer.append("// F fv { } // illformed\n"); //$NON-NLS-1$
buffer.append("void fv() { } // OK: definition of fv\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3660,7 +3659,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("FIC f; // OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("FIC S::*pm = &S::f; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3681,7 +3680,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("*fpi(int),\n"); //$NON-NLS-1$
buffer.append("(*pif)(const char*, const char*);\n"); //$NON-NLS-1$
buffer.append("(*fpif(int))(int);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3694,7 +3693,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("typedef int IFUNC(int);\n"); //$NON-NLS-1$
buffer.append("IFUNC* fpif(int);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3711,7 +3710,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f() {\n"); //$NON-NLS-1$
buffer.append("point(1,2); point(1); point();\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3762,7 +3761,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("f(6); //OK, calls f(6, 7)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -3791,7 +3790,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("g(); // g(f(::a))\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3816,7 +3815,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{ } // specified in class scope\n"); //$NON-NLS-1$
buffer.append("void C::g(int i = 88, int j) // in this translation unit,\n"); //$NON-NLS-1$
buffer.append("{ }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3837,7 +3836,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("extern void g(int x = i); // error\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3852,7 +3851,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class A {\n"); //$NON-NLS-1$
buffer.append("void f(A* p = this) { } // error\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3873,7 +3872,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int I;\n"); //$NON-NLS-1$
buffer.append("int g(float I, int b = I(2)); // error: parameter I found\n"); //$NON-NLS-1$
buffer.append("int h(int a, int b = sizeof(a)); // error, parameter a used\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -3898,7 +3897,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int mem2(int i = b); // OK; use X::b\n"); //$NON-NLS-1$
buffer.append("static int b;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3923,7 +3922,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("int (*p1)(int) = &f;\n"); //$NON-NLS-1$
buffer.append("int (*p2)() = &f; // error: type mismatch\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -3958,7 +3957,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("pa->f(); //OK, calls pa->B::f(7)\n"); //$NON-NLS-1$
buffer.append("pb->f(); //error: wrong number of arguments for B::f()\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -3977,7 +3976,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int m = (a > b) ? a : b;\n"); //$NON-NLS-1$
buffer.append("return (m > c) ? m : c;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4000,7 +3999,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("int X::a = 1;\n"); //$NON-NLS-1$
buffer.append("int X::b = a; // X::b = X::a\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4023,7 +4022,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int j;\n"); //$NON-NLS-1$
buffer.append("} b;\n"); //$NON-NLS-1$
buffer.append("} a = { 1, { 2, 3 } };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4034,7 +4033,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test8_5_1s4() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int x[] = { 1, 3, 5 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4053,7 +4052,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("static int s;\n"); //$NON-NLS-1$
buffer.append("int j;\n"); //$NON-NLS-1$
buffer.append("} a = { 1, 2 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4064,7 +4063,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test8_5_1s6() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("char cv[4] = { 'a', 's', 'd', 'f', 0 }; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4077,7 +4076,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("struct S { int a; char* b; int c; };\n"); //$NON-NLS-1$
buffer.append("S ss = { 1, \"asdf\" };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4096,7 +4095,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("S s;\n"); //$NON-NLS-1$
buffer.append("int i;\n"); //$NON-NLS-1$
buffer.append("} a = { { } , 3 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4113,7 +4112,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("float y[4][3] = {\n"); //$NON-NLS-1$
buffer.append("{ 1 }, { 2 }, { 3 }, { 4 }\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4132,7 +4131,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{ 2, 4, 6 },\n"); //$NON-NLS-1$
buffer.append("{ 3, 5, 7 },\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4147,7 +4146,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("float y[4][3] = {\n"); //$NON-NLS-1$
buffer.append("1, 3, 5, 2, 4, 6, 3, 5, 7\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4176,7 +4175,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("A a;\n"); //$NON-NLS-1$
buffer.append("B b = { 4, a, a };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4197,7 +4196,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("u c = 1; // error\n"); //$NON-NLS-1$
buffer.append("u d = { 0, \"asdf\" }; // error\n"); //$NON-NLS-1$
buffer.append("u e = { \"asdf\" }; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4208,7 +4207,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test8_5_2s2() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append(" char cv[4] = \"asdf\"; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4221,7 +4220,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("int& r1; // error: initializer missing\n"); //$NON-NLS-1$
buffer.append("extern int& r2; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4244,7 +4243,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct B : public A { } b;\n"); //$NON-NLS-1$
buffer.append("A& ra = b; // ra refers to A subobject in b\n"); //$NON-NLS-1$
buffer.append("const A& rca = b; // rca refers to A subobject in b\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4259,7 +4258,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("double& rd2 = 2.0; // error: not an lvalue and reference not const\n"); //$NON-NLS-1$
buffer.append("int i = 2;\n"); //$NON-NLS-1$
buffer.append("double& rd3 = i; // error: type mismatch and reference not const\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4280,7 +4279,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const A& rca = f(); // Either bound to the A subobject of the B rvalue,\n"); //$NON-NLS-1$
buffer.append("// or the entire B object is copied and the reference\n"); //$NON-NLS-1$
buffer.append("// is bound to the A subobject of the copy\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4295,7 +4294,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0\n"); //$NON-NLS-1$
buffer.append("const volatile int cvi = 1;\n"); //$NON-NLS-1$
buffer.append("const int& r = cvi; // error: type qualifiers dropped\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4326,7 +4325,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int f(Y);\n"); //$NON-NLS-1$
buffer.append("struct S { int a; };\n"); //$NON-NLS-1$
buffer.append("struct S { int a; }; // error, double definition\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4363,7 +4362,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("stat(ps); //call stat()\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4390,7 +4389,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct s { char* p; }; // define local struct s\n"); //$NON-NLS-1$
buffer.append("struct s; // redeclaration, has no effect\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4417,7 +4416,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("friend Vector operator*(Matrix&, Vector&);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4438,7 +4437,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct s* p = new struct s; // global s\n"); //$NON-NLS-1$
buffer.append("p->a = s; // local s\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4449,7 +4448,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test9_1s4() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("class A * A;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4472,7 +4471,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("tnode *right;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("tnode s, *sp;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4493,7 +4492,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f(T);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("void X::f(T t = count) { }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4522,7 +4521,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("fv S::* pmfv1 = &S::memfunc1;\n"); //$NON-NLS-1$
buffer.append("fv S::* pmfv2 = &S::memfunc2;\n"); //$NON-NLS-1$
buffer.append("fvc S::* pmfv3 = &S::memfunc3;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4573,7 +4572,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("n1.set(\"abc\",&n2,0);\n"); //$NON-NLS-1$
buffer.append("n2.set(\"def\",0,0);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4590,7 +4589,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void g() const;\n"); //$NON-NLS-1$
buffer.append("void h() const volatile;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4613,7 +4612,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int h() const { return a++; } // error\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("int s::f() const { return a; }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4650,7 +4649,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("y.f();\n"); //$NON-NLS-1$
buffer.append("y.g(); //error\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4679,7 +4678,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("process::reschedule(); // OK: no object necessary\n"); //$NON-NLS-1$
buffer.append("g().reschedule(); // g() is called\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4704,7 +4703,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("static int i;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("int Y::i = g(); // equivalent to Y::g();\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4725,7 +4724,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("process* process::running = get_main();\n"); //$NON-NLS-1$
buffer.append("process* process::run_chain = running;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4744,7 +4743,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("aa = 1; // error\n"); //$NON-NLS-1$
buffer.append("ptr->aa = 1; // OK\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4773,7 +4772,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("if (a.b == t) // shall yield true\n"); //$NON-NLS-1$
buffer.append("{ }\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4828,7 +4827,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("inner* p = 0; // error: inner not in scope\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4855,7 +4854,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("int enclose::inner::x = 1;\n"); //$NON-NLS-1$
buffer.append("void enclose::inner::f(int i) { }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4876,7 +4875,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class I1 {}; // definition of nested class\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("class E::I2 {}; // definition of nested class\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4915,7 +4914,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("local* p = 0; // error: local not in scope\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4944,7 +4943,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("Y c; // error\n"); //$NON-NLS-1$
buffer.append("X::Y d; // OK\n"); //$NON-NLS-1$
buffer.append("X::I e; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -4977,7 +4976,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("public:\n"); //$NON-NLS-1$
buffer.append("int c;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -4994,7 +4993,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class B { };\n"); //$NON-NLS-1$
buffer.append("class C { };\n"); //$NON-NLS-1$
buffer.append("class D : public A, public B, public C { };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5007,7 +5006,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("class X { };\n"); //$NON-NLS-1$
buffer.append("class Y : public X, public X { }; // illformed\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5027,7 +5026,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class C : public A, public B { void f(); }; // wellformed\n"); //$NON-NLS-1$
buffer.append("class D : public A, public L { void f(); }; // wellformed\n"); //$NON-NLS-1$
buffer.append("\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5094,7 +5093,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("pc->h(); //OK\n"); //$NON-NLS-1$
buffer.append("pc->h(1); //OK\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5125,7 +5124,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class C : public A, public B {\n"); //$NON-NLS-1$
buffer.append("int f() { return A::f() + B::f(); }\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5170,7 +5169,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("e; // OK: only one e (enumerator)\n"); //$NON-NLS-1$
buffer.append("pd->a++; //error, ambiguous: two as in D\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5199,7 +5198,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("class C : public virtual V, public W { };\n"); //$NON-NLS-1$
buffer.append("class D : public B, public C { void glorp(); };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5232,7 +5231,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A* pa = &d; // error, ambiguous: C’s A or B’s A?\n"); //$NON-NLS-1$
buffer.append("V* pv = &d; // OK: only one V subobject\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5269,7 +5268,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("c.f(); //calls B::f, the final overrider\n"); //$NON-NLS-1$
buffer.append("c.C::f(); //calls A::f because of the usingdeclaration\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5352,7 +5351,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// convert the result to B*\n"); //$NON-NLS-1$
buffer.append("dp->vf2(); //illformed: argument mismatch\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5405,7 +5404,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("ap->f(); //calls D::B1::f\n"); //$NON-NLS-1$
buffer.append("dp->f(); //illformed: ambiguous\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5442,7 +5441,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct Okay : VB1, VB2 {\n"); //$NON-NLS-1$
buffer.append("void f();\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5469,7 +5468,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("VB1a* vb1ap = new Da;\n"); //$NON-NLS-1$
buffer.append("vb1ap->f(); //calls VB2::f\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5484,7 +5483,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class B { public: virtual void f(); };\n"); //$NON-NLS-1$
buffer.append("class D : public B { public: void f(); };\n"); //$NON-NLS-1$
buffer.append("void D::f() { B::f(); }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5515,7 +5514,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("virtual void draw() = 0; // pure virtual\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5530,7 +5529,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct C {\n"); //$NON-NLS-1$
buffer.append("virtual void f() { }=0; // illformed\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5549,7 +5548,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("shape f(); // error\n"); //$NON-NLS-1$
buffer.append("void g(shape); // error\n"); //$NON-NLS-1$
buffer.append("shape& h(shape&); // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5570,7 +5569,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void rotate(int) {}\n"); //$NON-NLS-1$
buffer.append("// ab_circle::draw() is a pure virtual\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5591,7 +5590,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void rotate(int) {}\n"); //$NON-NLS-1$
buffer.append("void draw(); // a definition is required somewhere\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -5612,7 +5611,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct S {\n"); //$NON-NLS-1$
buffer.append("int a; // S::a is public by default\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5643,7 +5642,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A::BB x; // OK, typedef name A::BB is public\n"); //$NON-NLS-1$
buffer.append("A::B y; // access error, A::B is private\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5672,7 +5671,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A::I g(A::I p = A::x);\n"); //$NON-NLS-1$
buffer.append("A::I g(A::I p) { return 0; }\n"); //$NON-NLS-1$
buffer.append("A::I A::x = 0;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5693,7 +5692,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("int D::E::m = 1; // OK, no access error on private E\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5714,7 +5713,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int b; // X::b is public\n"); //$NON-NLS-1$
buffer.append("int c; // X::c is public\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5741,7 +5740,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("public:\n"); //$NON-NLS-1$
buffer.append("int d; // S::d is public\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5760,7 +5759,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("private:\n"); //$NON-NLS-1$
buffer.append("class A { }; // error: cannot change access\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5787,7 +5786,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct D6 : B { }; // B public by default\n"); //$NON-NLS-1$
buffer.append("class D7 : protected B { };\n"); //$NON-NLS-1$
buffer.append("struct D8 : protected B { };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5838,7 +5837,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B* bp2 = (B*)this; // OK with cast\n"); //$NON-NLS-1$
buffer.append("bp2->mi = 3; // OK: access through a pointer to B.\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5869,7 +5868,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p->i = 1; // OK: B* can be implicitly cast to A*,\n"); //$NON-NLS-1$
buffer.append("// and f has access to i in A\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5940,7 +5939,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("int ef(D&);\n"); //$NON-NLS-1$
buffer.append("int ff(X&);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -5977,7 +5976,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("friend_set(&obj,10);\n"); //$NON-NLS-1$
buffer.append("obj.member_set(10);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6012,7 +6011,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// to declare members of nested class of X\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6041,7 +6040,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class Z {\n"); //$NON-NLS-1$
buffer.append("int v[X::a]; // error: X::a is private\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6058,7 +6057,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("friend char* X::foo(int);\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6075,7 +6074,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("friend void f() { } // definition of global f, a friend of M,\n"); //$NON-NLS-1$
buffer.append("// not the definition of a member function\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6126,7 +6125,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// despite being derived from a friend\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6167,7 +6166,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X *px; // OK, but ::X is found\n"); //$NON-NLS-1$
buffer.append("Z *pz; // error, no Z is found\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6256,7 +6255,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p1->i = 2; // illformed\n"); //$NON-NLS-1$
buffer.append("p2->i = 3; // illformed\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6299,7 +6298,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// D::f() is invoked\n"); //$NON-NLS-1$
buffer.append("pd->f(); //error: D::f() is private\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6320,7 +6319,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("class C : public A, public B {\n"); //$NON-NLS-1$
buffer.append("void f() { W::f(); } // OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6361,7 +6360,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("return p->y; // error: I::y is private\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6392,7 +6391,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("C::B *t; // error, C::B is inaccessible\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6411,7 +6410,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("C(); //declares the constructor\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("C::C() { } // defines the constructor\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6446,7 +6445,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("cout << cobj.c * 100 // value of cobj.c is unspecified\n"); //$NON-NLS-1$
buffer.append("<< '\n';\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6485,7 +6484,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X b = f(X(2));\n"); //$NON-NLS-1$
buffer.append("a = f(a);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6516,7 +6515,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("C obj1;\n"); //$NON-NLS-1$
buffer.append("const C& cr = C(16)+C(23);\n"); //$NON-NLS-1$
buffer.append("C obj2;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6554,7 +6553,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// a.operator X().operator int() not tried\n"); //$NON-NLS-1$
buffer.append("int c = X(a); // OK: a.operator X().operator int()\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6597,7 +6596,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6632,7 +6631,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("a = 2; // a = X(2)\n"); //$NON-NLS-1$
buffer.append("f(3); // f(X(3))\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6667,7 +6666,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("Z* p = new Z(1); // OK: direct initialization syntax used\n"); //$NON-NLS-1$
buffer.append("Z a4 = (Z)1; // OK: explicit cast used\n"); //$NON-NLS-1$
buffer.append("Z a5 = static_cast<Z>(1); // OK: explicit cast used\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6698,7 +6697,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("i = (int)a;\n"); //$NON-NLS-1$
buffer.append("i = a;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6721,7 +6720,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("if (a) { // ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6762,7 +6761,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B_ptr->B_alias::~B(); // calls B’s destructor\n"); //$NON-NLS-1$
buffer.append("B_ptr->B_alias::~B_alias(); // error, no B_alias in class B\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6799,7 +6798,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(p);\n"); //$NON-NLS-1$
buffer.append("p->X::~X(); //cleanup\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6834,7 +6833,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("new D1[i]; // calls ::operator new[](size_t)\n"); //$NON-NLS-1$
buffer.append("new D1; // illformed: ::operator new(size_t) hidden\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6863,7 +6862,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void operator delete(void*, size_t);\n"); //$NON-NLS-1$
buffer.append("void operator delete[](void*);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -6922,7 +6921,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// copy it into f\n"); //$NON-NLS-1$
buffer.append("complex g = { 1, 2 }; // error; constructor is required\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6961,7 +6960,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("float f;\n"); //$NON-NLS-1$
buffer.append("complex c;\n"); //$NON-NLS-1$
buffer.append("} x = { 99, 88.8, 77.7 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6980,7 +6979,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct B { };\n"); //$NON-NLS-1$
buffer.append("struct C: public A, public B { C(); };\n"); //$NON-NLS-1$
buffer.append("C::C(): global_A() { } // meminitializer for base A\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -6997,7 +6996,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct B: public virtual A { };\n"); //$NON-NLS-1$
buffer.append("struct C: public A, public B { C(); };\n"); //$NON-NLS-1$
buffer.append("C::C(): A() { } // illformed: which A?\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -7026,7 +7025,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("D::D(int a) : B2(a+1), B1(a+2), c(a+3), b(a+4)\n"); //$NON-NLS-1$
buffer.append("{ }\n"); //$NON-NLS-1$
buffer.append("D d(10);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7097,7 +7096,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A a(2); // use V(int)\n"); //$NON-NLS-1$
buffer.append("B b(3); // use V()\n"); //$NON-NLS-1$
buffer.append("C c(4); // use V()\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7124,7 +7123,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const int& r;\n"); //$NON-NLS-1$
buffer.append("X(int i): r(a), b(i), i(i), j(this->i) {}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7179,7 +7178,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// but base C not yet initialized\n"); //$NON-NLS-1$
buffer.append("i(f()) {} // welldefined: bases are all initialized\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7214,7 +7213,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("extern X xobj;\n"); //$NON-NLS-1$
buffer.append("int* p3 = &xobj.i; // OK, X is a POD class\n"); //$NON-NLS-1$
buffer.append("X xobj;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7240,7 +7239,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{ }\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7301,7 +7300,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("v->g(); // v is base of B, the call is welldefined, calls B::g\n"); //$NON-NLS-1$
buffer.append("a->f(); //undefined behavior, a’s type not a base of B\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7356,7 +7355,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("dynamic_cast<B*>(a); // undefined behavior,\n"); //$NON-NLS-1$
buffer.append("// a has type A*, A not a base of B\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7383,7 +7382,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X a(1); // calls X(int);\n"); //$NON-NLS-1$
buffer.append("X b(a, 0); // calls X(const X&, int);\n"); //$NON-NLS-1$
buffer.append("X c = b; // calls X(const X&, int);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7404,7 +7403,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X(const X&);\n"); //$NON-NLS-1$
buffer.append("X(X&); //OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7425,7 +7424,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("const X cx;\n"); //$NON-NLS-1$
buffer.append("X x = cx; // error - X::X(X&) cannot copy cx into x\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7448,7 +7447,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void g() {\n"); //$NON-NLS-1$
buffer.append("S a( f() ); // does not instantiate member template\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -7459,17 +7458,14 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
void h(int (*x)()) { } // illformed: redefinition of h(int())
--End Example]
*/
- public void test12_8s3d() { // TODO assert redefinition problem
+ public void test12_8s3d() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("void h(int());\n"); //$NON-NLS-1$
buffer.append("void h(int (*)()); // redeclaration of h(int())\n"); //$NON-NLS-1$
buffer.append("void h(int x()) { } // definition of h(int())\n"); //$NON-NLS-1$
buffer.append("void h(int (*x)()) { } // illformed: redefinition of h(int())\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
- assertTrue(false);
- } catch (Exception e) {
- }
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 1);
}
/**
@@ -7484,7 +7480,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct X {\n"); //$NON-NLS-1$
buffer.append("X(const X&, int);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7501,7 +7497,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X(const X&, int);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("X::X(const X& x, int i =0) { }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7530,7 +7526,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("x = cx; // error:\n"); //$NON-NLS-1$
buffer.append("// X::operator=(X&) cannot assign cx into x\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7547,7 +7543,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct A : virtual V { };\n"); //$NON-NLS-1$
buffer.append("struct B : virtual V { };\n"); //$NON-NLS-1$
buffer.append("struct C : B, A { };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7582,7 +7578,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("return t;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("Thing t2 = f();\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7603,7 +7599,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("abs(1); //call abs(int);\n"); //$NON-NLS-1$
buffer.append("abs(1.0); //call abs(double);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7630,7 +7626,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void g() const; // OK: no static g\n"); //$NON-NLS-1$
buffer.append("void g() const volatile; // OK: no static g\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7642,18 +7638,15 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
void f(Int i) { } // error: redefinition of f(int)
--End Example]
*/
- public void test12_1s3a() throws Exception { //TODO better assert of expected redefinition problem
+ public void test12_1s3a() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("typedef int Int;\n"); //$NON-NLS-1$
buffer.append("void f(int i);\n"); //$NON-NLS-1$
buffer.append("void f(Int i); // OK: redeclaration of f(int)\n"); //$NON-NLS-1$
buffer.append("void f(int i) { }\n"); //$NON-NLS-1$
buffer.append("void f(Int i) { } // error: redefinition of f(int)\n"); //$NON-NLS-1$
- try{
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
- } catch ( ParserException e ){
- assertEquals( e.getMessage(), "found IProblemBinding" ); //$NON-NLS-1$
- }
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 1);
}
/**
@@ -7668,7 +7661,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("enum E { a };\n"); //$NON-NLS-1$
buffer.append("void f(int i) { }\n"); //$NON-NLS-1$
buffer.append("void f(E i) { }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7693,7 +7686,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int g(char[5][10]); // same as g(char(*)[10]);\n"); //$NON-NLS-1$
buffer.append("int g(char[7][10]); // same as g(char(*)[10]);\n"); //$NON-NLS-1$
buffer.append("int g(char(*)[20]); // different from g(char(*)[10]);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7712,7 +7705,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int f (const int); // redeclaration of f(int)\n"); //$NON-NLS-1$
buffer.append("int f (int) { } // definition of f(int)\n"); //$NON-NLS-1$
buffer.append("int f (cInt) { } // error: redefinition of f(int)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7741,7 +7734,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f (1); // OK: call f(int, int)\n"); //$NON-NLS-1$
buffer.append("f (); // Error: f(int, int) or f()?\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -7766,7 +7759,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("public:\n"); //$NON-NLS-1$
buffer.append("int f(char*);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7805,7 +7798,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("pd->B::f(1); //OK\n"); //$NON-NLS-1$
buffer.append("pd->f(\"Ben\"); //OK, calls D::f\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -7844,7 +7837,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("callee(88, 99); // error: only callee(int) in scope\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -7875,7 +7868,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("buffer(int s) { p = new char[size = s]; }\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7906,7 +7899,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("T a = 1; // illformed: T(C(1)) not tried\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7935,7 +7928,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("} a;\n"); //$NON-NLS-1$
buffer.append("int i = a(1); // Calls f1 via pointer returned from\n"); //$NON-NLS-1$
buffer.append("// conversion function\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7974,7 +7967,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// user defined types exist which\n"); //$NON-NLS-1$
buffer.append("// would perform the operation.\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -7999,7 +7992,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A a, b;\n"); //$NON-NLS-1$
buffer.append("a + b; // operator+(a,b) chosen over int(a) + int(b)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8028,7 +8021,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// a conversion to int\n"); //$NON-NLS-1$
buffer.append("float x = a; // ambiguous: both possibilities require conversions,\n"); //$NON-NLS-1$
buffer.append("// and neither is better than the other\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8067,7 +8060,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// &i ® int* is better than &i ® const int*\n"); //$NON-NLS-1$
buffer.append("// and c ® int is better than c ® short\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8094,7 +8087,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B b;\n"); //$NON-NLS-1$
buffer.append("f(b); //ambiguous because b ­> C via constructor and\n"); //$NON-NLS-1$
buffer.append("// b -> A via constructor or conversion function.\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8115,7 +8108,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int f(B&);\n"); //$NON-NLS-1$
buffer.append("int i = f(b); // Calls f(B&), an exact match, rather than\n"); //$NON-NLS-1$
buffer.append("// f(A&), a conversion\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8132,7 +8125,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int f(int *);\n"); //$NON-NLS-1$
buffer.append("int i;\n"); //$NON-NLS-1$
buffer.append("int j = f(&i); // Calls f(int *)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8175,7 +8168,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("a.f(); //CallsX::f() const\n"); //$NON-NLS-1$
buffer.append("b.f(); //Calls X::f()\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8199,7 +8192,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i = f(a); // Calls f(int), because short -> int is\n"); //$NON-NLS-1$
buffer.append("// better than short -> float.\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8222,7 +8215,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int f(A *);\n"); //$NON-NLS-1$
buffer.append("int f(B *);\n"); //$NON-NLS-1$
buffer.append("int i = f(pc); // Calls f(B *)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8249,7 +8242,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int (*p3)(long) = &X::f; // OK\n"); //$NON-NLS-1$
buffer.append("int (X::*p4)(long) = &X::f; // error: mismatch\n"); //$NON-NLS-1$
buffer.append("int (*p6)(long) = &(X::f); // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8276,7 +8269,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("complex z = a.operator+(b); // complex z = a+b;\n"); //$NON-NLS-1$
buffer.append("void* p = operator new(sizeof(int)*n);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8323,7 +8316,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("dobj1 = dobj2; // calls implicitlydeclared\n"); //$NON-NLS-1$
buffer.append("// D::operator=(const D&)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8368,7 +8361,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("operator++(b); //explicit call: like ++b;\n"); //$NON-NLS-1$
buffer.append("operator++(b, 0); // explicit call: like b++;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8395,7 +8388,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int& ri = i; // error: nonconst reference bound to temporary\n"); //$NON-NLS-1$
buffer.append("const int& cri = i; // OK: const reference bound to temporary\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8410,7 +8403,33 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<double d> class X; // error\n"); //$NON-NLS-1$
buffer.append("template<double* pd> class Y; // OK\n"); //$NON-NLS-1$
buffer.append("template<double& rd> class Z; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
+ }
+
+ /**
+ [--Start Example(CPP 14.1-8):
+ template<int *a> struct R { };
+ template<int b[5]> struct S { };
+ int *p;
+ R<p> w; // OK
+ S<p> x; // OK due to parameter adjustment
+ int v[5];
+ R<v> y; // OK due to implicit argument conversion
+ S<v> z; // OK due to both adjustment and conversion
+ --End Example]
+ */
+ public void test14_1s8() throws Exception { // TODO raised bug 90668
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<int *a> struct R { };\n"); //$NON-NLS-1$
+ buffer.append("template<int b[5]> struct S { };\n"); //$NON-NLS-1$
+ buffer.append("int *p;\n"); //$NON-NLS-1$
+ buffer.append("R<p> w; // OK\n"); //$NON-NLS-1$
+ buffer.append("S<p> x; // OK due to parameter adjustment\n"); //$NON-NLS-1$
+ buffer.append("int v[5];\n"); //$NON-NLS-1$
+ buffer.append("R<v> y; // OK due to implicit argument conversion\n"); //$NON-NLS-1$
+ buffer.append("S<v> z; // OK due to both adjustment and conversion\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8423,7 +8442,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T1, class T2 = int> class A;\n"); //$NON-NLS-1$
buffer.append("template<class T1 = int, class T2> class A;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8434,7 +8453,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_1s10b() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T1 = int, class T2 = int> class A;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8445,7 +8464,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_1s11() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T1 = int, class T2> class B; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8458,7 +8477,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T = int> class X;\n"); //$NON-NLS-1$
buffer.append("template<class T = int> class X { }; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8471,7 +8490,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template<int i = (3 > 4) > // OK\n"); //$NON-NLS-1$
buffer.append("class Y { };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8490,7 +8509,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class T> class Y { };\n"); //$NON-NLS-1$
buffer.append("Y< X<1> > x3; // OK\n"); //$NON-NLS-1$
buffer.append("Y<X<6>> 1> > x4; // OK: Y< X< (6>>1) > >\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8531,7 +8550,31 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("T::template adjust<100>();\n"); //$NON-NLS-1$
buffer.append("// OK: < starts explicit qualification\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
+ }
+
+ /**
+ [--Start Example(CPP 14.3-5):
+ template<class T> struct A {
+ ~A();
+ };
+ void f(A<int>* p, A<int>* q) {
+ p->A<int>::~A(); // OK: destructor call
+ q->A<int>::~A<int>(); // OK: destructor call
+ }
+ --End Example]
+ */
+ public void test14_3s5() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> struct A {\n"); //$NON-NLS-1$
+ buffer.append("~A();\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("void f(A<int>* p, A<int>* q) {\n"); //$NON-NLS-1$
+ buffer.append("p->A<int>::~A(); // OK: destructor call\n"); //$NON-NLS-1$
+ buffer.append("q->A<int>::~A<int>(); // OK: destructor call\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8576,7 +8619,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("v1[3] = 7;\n"); //$NON-NLS-1$
buffer.append("v2[3] = v3.elem(4) = dcomplex(7,8);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8607,7 +8650,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// OK: even though Y::S is private\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("X<Y::S> y; // error: S not accessible\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8630,7 +8673,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X<S> x3; // error: local type used as templateargument\n"); //$NON-NLS-1$
buffer.append("X<S*> x4; // error: pointer to local type used as templateargument\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8651,7 +8694,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int function();\n"); //$NON-NLS-1$
buffer.append("A<function> a; // illformed: would declare A<function>::t\n"); //$NON-NLS-1$
buffer.append("// as a static member function\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8688,7 +8731,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// so c.y.x has type int\n"); //$NON-NLS-1$
buffer.append("// V<int*> within C<A> uses the partial specialization,\n"); //$NON-NLS-1$
buffer.append("// so c.z.x has type long\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8703,7 +8746,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class E, int size> class buffer { };\n"); //$NON-NLS-1$
buffer.append("buffer<char,2*512> x;\n"); //$NON-NLS-1$
buffer.append("buffer<char,1024> y;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8722,7 +8765,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("list<int,&error_handler2> x2;\n"); //$NON-NLS-1$
buffer.append("list<int,&error_handler2> x3;\n"); //$NON-NLS-1$
buffer.append("list<char,&error_handler2> x4;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8749,7 +8792,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("T& elem(int i) { return v[i]; }\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8768,7 +8811,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f2();\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("template<class T2, class T1> void A<T2,T1>::f1() { } // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8805,7 +8848,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("if (i<0 || sz<=i) error(\"Array: range error\");\n"); //$NON-NLS-1$
buffer.append("return v[i];\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8822,7 +8865,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("Array<dcomplex> v2(30);\n"); //$NON-NLS-1$
buffer.append("v1[3] = 7; // Array<int>::operator[]()\n"); //$NON-NLS-1$
buffer.append("v2[3] = dcomplex(7,8); // Array<dcomplex>::operator[]()\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8843,7 +8886,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A<int>::B* b1; // OK: requires A to be defined but not A::B\n"); //$NON-NLS-1$
buffer.append("template<class T> class A<T>::B { };\n"); //$NON-NLS-1$
buffer.append("A<int>::B b2; // OK: requires A::B to be defined\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8872,43 +8915,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
- /**
- [--Start Example(CPP 14.5.2-2):
- template <class T> struct A {
- void f(int);
- template <class T2> void f(T2);
- };
- template <> void A<int>::f(int) { } // nontemplate member
- template <> template <> void A<int>::f<>(int) { } // template member
- int main()
- {
- A<char> ac;
- ac.f(1); //nontemplate
- ac.f('c'); //template
- ac.f<>(1); //template
- }
- --End Example]
- */
- public void test14_5_2s2() throws Exception {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template <class T> struct A {\n"); //$NON-NLS-1$
- buffer.append("void f(int);\n"); //$NON-NLS-1$
- buffer.append("template <class T2> void f(T2);\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("template <> void A<int>::f(int) { } // nontemplate member\n"); //$NON-NLS-1$
- buffer.append("template <> template <> void A<int>::f<>(int) { } // template member\n"); //$NON-NLS-1$
- buffer.append("int main()\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("A<char> ac;\n"); //$NON-NLS-1$
- buffer.append("ac.f(1); //nontemplate\n"); //$NON-NLS-1$
- buffer.append("ac.f('c'); //template\n"); //$NON-NLS-1$
- buffer.append("ac.f<>(1); //template\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- }
+
/**
[--Start Example(CPP 14.5.2-4):
@@ -8932,7 +8942,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f(int i) { f<>(i); } // overriding function that calls\n"); //$NON-NLS-1$
buffer.append("// the template instantiation\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -8967,7 +8977,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("ip = a.operator int*(); // explicit call to template operator\n"); //$NON-NLS-1$
buffer.append("// A::operator int*()\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -8985,7 +8995,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("template<class T> T X<T>::s = 0;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9024,7 +9034,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9041,7 +9051,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class T> friend class B; // OK\n"); //$NON-NLS-1$
buffer.append("template<class T> friend void f(T){ } // OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9062,7 +9072,33 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("template<class T> struct A { X::Y ab; }; // OK\n"); //$NON-NLS-1$
buffer.append("template<class T> struct A<T*> { X::Y ab; }; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
+ }
+
+ /**
+ [--Start Example(CPP 14.5.3-6):
+ template<class T> struct A {
+ struct B { };
+ void f();
+ };
+ class C {
+ template<class T> friend struct A<T>::B;
+ template<class T> friend void A<T>::f();
+ };
+ --End Example]
+ */
+ public void test14_5_3s6() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> struct A {\n"); //$NON-NLS-1$
+ buffer.append("struct B { };\n"); //$NON-NLS-1$
+ buffer.append("void f();\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("class C {\n"); //$NON-NLS-1$
+ buffer.append("template<class T> friend struct A<T>::B;\n"); //$NON-NLS-1$
+ buffer.append("template<class T> friend void A<T>::f();\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9081,7 +9117,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class T1, class T2, int I> class A<T1*, T2, I> { }; // #3\n"); //$NON-NLS-1$
buffer.append("template<class T> class A<int, T*, 5> { }; // #4\n"); //$NON-NLS-1$
buffer.append("template<class T1, class T2, int I> class A<T1, T2*, I> { }; // #5\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9094,7 +9130,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template <int I, int J> struct B {};\n"); //$NON-NLS-1$
buffer.append("template <int I> struct B<I, I> {}; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9121,7 +9157,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("A<int, int*, 1> a2; // uses #2, T is int, I is 1\n"); //$NON-NLS-1$
buffer.append("A<int, char*, 5> a3; // uses #4, T is char\n"); //$NON-NLS-1$
buffer.append("A<int, char*, 1> a4; // uses #5, T1 is int, T2 is char, I is 1\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9136,32 +9172,13 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
*/
public void test14_5_4_1s2b() throws Exception {
StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T1, class T2, int I> class A { }; // #1\n"); //$NON-NLS-1$
- buffer.append("template<class T, int I> class A<T, T*, I> { }; // #2\n"); //$NON-NLS-1$
+ buffer.append("template<class T1, class T2, int I> class A { }; // #1\n"); //$NON-NLS-1$
+ buffer.append("template<class T, int I> class A<T, T*, I> { }; // #2\n"); //$NON-NLS-1$
buffer.append("template<class T1, class T2, int I> class A<T1*, T2, I> { }; // #3\n"); //$NON-NLS-1$
- buffer.append("template<class T> class A<int, T*, 5> { }; // #4\n"); //$NON-NLS-1$
+ buffer.append("template<class T> class A<int, T*, 5> { }; // #4\n"); //$NON-NLS-1$
buffer.append("template<class T1, class T2, int I> class A<T1, T2*, I> { }; // #5\n"); //$NON-NLS-1$
- buffer.append("A<int*, int*, 2> a5; // ambiguous: matches #3 and #5\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
- }
-
- /**
- [--Start Example(CPP 14.5.4.2-2):
- template<int I, int J, class T> class X { };
- template<int I, int J> class X<I, J, int> { }; // #1
- template<int I> class X<I, I, int> { }; // #2
- template<int I, int J> void f(X<I, J, int>); // #A
- template<int I> void f(X<I, I, int>); // #B
- --End Example]
- */
- public void test14_5_4_2s2() throws Exception {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<int I, int J, class T> class X { };\n"); //$NON-NLS-1$
- buffer.append("template<int I, int J> class X<I, J, int> { }; // #1\n"); //$NON-NLS-1$
- buffer.append("template<int I> class X<I, I, int> { }; // #2\n"); //$NON-NLS-1$
- buffer.append("template<int I, int J> void f(X<I, J, int>); // #A\n"); //$NON-NLS-1$
- buffer.append("template<int I> void f(X<I, I, int>); // #B\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ buffer.append("A<int*, int*, 2> a5; // ambiguous: matches #3 and #5 : expect problem \n"); //$NON-NLS-1$
+ parse(buffer.toString(), ParserLanguage.CPP, true, 1);
}
/**
@@ -9224,7 +9241,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("a2.f(); //illformed, no definition of f for A<T,2>\n"); //$NON-NLS-1$
buffer.append("// the primary template is not used here\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9237,10 +9254,57 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T> class Array { };\n"); //$NON-NLS-1$
buffer.append("template<class T> void sort(Array<T>&);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
+ [--Start Example(CPP 14.5.5.1-1a):
+ // file1.c
+ template<class T>
+ void f(T*);
+ void g(int* p) {
+ f(p); // call
+ // f<int>(int*)
+ }
+ }
+ --End Example]
+ */
+ public void test14_5_5_1s1a() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("// file1.c \n"); //$NON-NLS-1$
+ buffer.append("template<class T>\n"); //$NON-NLS-1$
+ buffer.append("void f(T*);\n"); //$NON-NLS-1$
+ buffer.append("void g(int* p) { \n"); //$NON-NLS-1$
+ buffer.append("f(p); // call \n"); //$NON-NLS-1$
+ buffer.append("// f<int>(int*) \n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
+ }
+ /**
+ [--Start Example(CPP 14.5.5.1-1b):
+ // file2.c
+ template<class T>
+ void f(T);
+ void h(int* p) {
+ f(p); // call
+ // f<int*>(int*)
+ }
+ --End Example]
+ */
+ public void test14_5_5_1s1b() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("// file2.c\n"); //$NON-NLS-1$
+ buffer.append("template<class T>\n"); //$NON-NLS-1$
+ buffer.append("void f(T);\n"); //$NON-NLS-1$
+ buffer.append("void h(int* p) {\n"); //$NON-NLS-1$
+ buffer.append("f(p); // call\n"); //$NON-NLS-1$
+ buffer.append("// f<int*>(int*)\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
+ }
+ /**
[--Start Example(CPP 14.5.5.2-5):
template<class T> struct A { A(); };
template<class T> void f(T);
@@ -9282,7 +9346,35 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("const A<int> z2;\n"); //$NON-NLS-1$
buffer.append("h(z2); // h(const T&) is called because h(A<T>&) is not callable\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
+ }
+
+ /**
+ [--Start Example(CPP 14.5.5.2-6):
+ 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;
+ f(ip); //calls #2
+ g(ip); //calls #4
+ }
+ --End Example]
+ */
+ public void test14_5_5_2s6() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T); // #1\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void f(T*, int=1); // #2\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void g(T); // #3\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void g(T*, ...); // #4\n"); //$NON-NLS-1$
+ buffer.append("int main() {\n"); //$NON-NLS-1$
+ buffer.append("int* ip;\n"); //$NON-NLS-1$
+ buffer.append("f(ip); //calls #2\n"); //$NON-NLS-1$
+ buffer.append("g(ip); //calls #4\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9331,7 +9423,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// no visible declarations of B and a8\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9356,7 +9448,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("typename T::X x; // illformed: finds the data member X\n"); //$NON-NLS-1$
buffer.append("// not the member type X\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9377,7 +9469,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f(A<T>::B); // illformed: typename required before A<T>::B\n"); //$NON-NLS-1$
buffer.append("typename A::B g(); // OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9420,7 +9512,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// not instantiated\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9459,7 +9551,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9502,7 +9594,28 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// by two calls of f(int)\n"); //$NON-NLS-1$
buffer.append("g('a'); //will cause three calls of f(char)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
+ }
+
+
+ /**
+ [--Start Example(CPP 14.6.1-1):
+ template<class T> class X {
+ X* p; // meaning X<T>
+ X<T>* p2;
+ X<int>* p3;
+ };
+ --End Example]
+ */
+ public void test14_6_1s1() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> class X {\n"); //$NON-NLS-1$
+ buffer.append("X* p; // meaning X<T>\n"); //$NON-NLS-1$
+ buffer.append("X<T>* p2;\n"); //$NON-NLS-1$
+ buffer.append("X<int>* p3;\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9521,7 +9634,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("Y* p; // meaning Y<int>\n"); //$NON-NLS-1$
buffer.append("Y<char>* q; // meaning Y<char>\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9534,7 +9647,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T> class X : public Array<T> { };\n"); //$NON-NLS-1$
buffer.append("template<class T> class Y : public T { };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9557,7 +9670,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("template<class X> class X; // error: templateparameter redeclared\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9580,7 +9693,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class B> void A<B>::f() {\n"); //$NON-NLS-1$
buffer.append("B b; // A’s B, not the template parameter\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9607,7 +9720,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B b; // A’s B\n"); //$NON-NLS-1$
buffer.append("a b; // error: A’s a isn’t a type name\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9630,7 +9743,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("pb->j++;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9665,7 +9778,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("Y* p; // Y<T>\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("Y<A> ya;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9702,7 +9815,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("void g(int); // not in scope at the point of the template\n"); //$NON-NLS-1$
buffer.append("// definition, not considered for the call g(1)\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9741,44 +9854,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// in its namespace (global scope)\n"); //$NON-NLS-1$
buffer.append("b = gcd(3,4); // illformed; gcd is not visible\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
- }
-
- /**
- [--Start Example(CPP 14.7-3):
- template<class T = int> struct A {
- static int x;
- };
- template<class U> void g(U) { }
- template<> struct A<double> { }; // specialize for T == double
- template<> struct A<> { }; // specialize for T == int
- template<> void g(char) { } // specialize for U == char
- // U is deduced from the parameter type
- template<> void g<int>(int) { } // specialize for U == int
- template<> int A<char>::x = 0; // specialize for T == char
- template<class T = int> struct B {
- static int x;
- };
- template<> int B<>::x = 1; // specialize for T == int
- --End Example]
- */
- public void test14_7s3() throws Exception {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T = int> struct A {\n"); //$NON-NLS-1$
- buffer.append("static int x;\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("template<class U> void g(U) { }\n"); //$NON-NLS-1$
- buffer.append("template<> struct A<double> { }; // specialize for T == double\n"); //$NON-NLS-1$
- buffer.append("template<> struct A<> { }; // specialize for T == int\n"); //$NON-NLS-1$
- buffer.append("template<> void g(char) { } // specialize for U == char\n"); //$NON-NLS-1$
- buffer.append("// U is deduced from the parameter type\n"); //$NON-NLS-1$
- buffer.append("template<> void g<int>(int) { } // specialize for U == int\n"); //$NON-NLS-1$
- buffer.append("template<> int A<char>::x = 0; // specialize for T == char\n"); //$NON-NLS-1$
- buffer.append("template<class T = int> struct B {\n"); //$NON-NLS-1$
- buffer.append("static int x;\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("template<> int B<>::x = 1; // specialize for T == int\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -9802,7 +9878,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X<int> aa;\n"); //$NON-NLS-1$
buffer.append("X<char*> bb;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9843,7 +9919,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("p->g(); //instantiation of class Z<char> required, and\n"); //$NON-NLS-1$
buffer.append("// instantiation of Z<char>::g() required\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9874,7 +9950,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// convert D<char>* to B<char>*\n"); //$NON-NLS-1$
buffer.append("delete ppp; // instantiation of D<double> required\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9887,7 +9963,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T> class X;\n"); //$NON-NLS-1$
buffer.append("X<char> ch; // error: definition of X required\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9931,7 +10007,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -9956,34 +10032,29 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(a, b); // default argument z = zdef(T()) instantiated\n"); //$NON-NLS-1$
buffer.append("f(a); //illformed; ydef is not declared\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
- [--Start Example(CPP 14.7.2-2):
- template<class T> class Array { void mf(); };
- template class Array<char>;
- template void Array<int>::mf();
- template<class T> void sort(Array<T>& v) { }
- template void sort(Array<char>&); // argument is deduced here
- namespace N {
- template<class T> void f(T&) { }
- }
- template void N::f<int>(int&);
+ [--Start Example(CPP 14.7.1-14):
+ template<class T> class X {
+ X<T>* p; // OK
+ X<T*> a; // implicit generation of X<T> requires
+ // the implicit instantiation of X<T*> which requires
+ // the implicit instantiation of X<T**> which ...
+ };
--End Example]
*/
- public void test14_7_2s2() throws Exception {
+ public void test14_7_1s14() throws Exception {
StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> class Array { void mf(); };\n"); //$NON-NLS-1$
- buffer.append("template class Array<char>;\n"); //$NON-NLS-1$
- buffer.append("template void Array<int>::mf();\n"); //$NON-NLS-1$
- buffer.append("template<class T> void sort(Array<T>& v) { }\n"); //$NON-NLS-1$
- buffer.append("template void sort(Array<char>&); // argument is deduced here\n"); //$NON-NLS-1$
- buffer.append("namespace N {\n"); //$NON-NLS-1$
- buffer.append("template<class T> void f(T&) { }\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- buffer.append("template void N::f<int>(int&);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ buffer.append("template<class T> class X {\n"); //$NON-NLS-1$
+ buffer.append("X<T>* p; // OK\n"); //$NON-NLS-1$
+ buffer.append("X<T*> a; // implicit generation of X<T> requires\n"); //$NON-NLS-1$
+ buffer.append("// the implicit instantiation of X<T*> which requires\n"); //$NON-NLS-1$
+ buffer.append("// the implicit instantiation of X<T**> which ...\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10012,7 +10083,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template class N::Y<char*>; // OK: explicit instantiation in namespace N\n"); //$NON-NLS-1$
buffer.append("template void N::Y<double>::mf(); // OK: explicit instantiation\n"); //$NON-NLS-1$
buffer.append("// in namespace N\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10027,7 +10098,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("char* p = 0;\n"); //$NON-NLS-1$
buffer.append("template<class T> T g(T = &p);\n"); //$NON-NLS-1$
buffer.append("template int g<int>(int); // OK even though &p isn’t an int.\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10042,7 +10113,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<> class X<int> { }; // error: X not a template\n"); //$NON-NLS-1$
buffer.append("template<class T> class X;\n"); //$NON-NLS-1$
buffer.append("template<> class X<char*> { }; // OK: X is a template\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10079,7 +10150,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// explicit specialization syntax not used for a member of\n"); //$NON-NLS-1$
buffer.append("// explicitly specialized class template specialization\n"); //$NON-NLS-1$
buffer.append("void A<int>::f() { }\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10108,7 +10179,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<> void sort<String>(Array<String>& v); // error: specialization\n"); //$NON-NLS-1$
buffer.append("// after use of primary template\n"); //$NON-NLS-1$
buffer.append("template<> void sort<>(Array<char*>& v); // OK: sort<char*> not yet used\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10137,7 +10208,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("template<> class N::Y<double> { }; // OK: specialization\n"); //$NON-NLS-1$
buffer.append("// in same namespace\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10154,26 +10225,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<> class X<int>;\n"); //$NON-NLS-1$
buffer.append("X<int>* p; // OK: pointer to declared class X<int>\n"); //$NON-NLS-1$
buffer.append("X<int> x; // error: object of incomplete class X<int>\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
- }
-
- /**
- [--Start Example(CPP 14.7.3-11):
- template<class T> class Array { };
- template<class T> void sort(Array<T>& v);
- // explicit specialization for sort(Array<int>&)
- // with deduces templateargument of type int
- template<> void sort(Array<int>&);
- --End Example]
- */
- public void test14_7_3s11() throws Exception {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> class Array { };\n"); //$NON-NLS-1$
- buffer.append("template<class T> void sort(Array<T>& v);\n"); //$NON-NLS-1$
- buffer.append("// explicit specialization for sort(Array<int>&)\n"); //$NON-NLS-1$
- buffer.append("// with deduces templateargument of type int\n"); //$NON-NLS-1$
- buffer.append("template<> void sort(Array<int>&);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10192,7 +10244,25 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template <> void f(int*); // Ambiguous\n"); //$NON-NLS-1$
buffer.append("template <> void f<int>(int*); // OK\n"); //$NON-NLS-1$
buffer.append("template <> void f(int); // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 1);
+ }
+
+ /**
+ [--Start Example(CPP 14.7.3-14):
+ 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
+ --End Example]
+ */
+ public void test14_7_3s14() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T) { }\n"); //$NON-NLS-1$
+ buffer.append("template<class T> inline T g(T) { }\n"); //$NON-NLS-1$
+ buffer.append("template<> inline void f<>(int) { } // OK: inline\n"); //$NON-NLS-1$
+ buffer.append("template<> int g<>(int) { } // OK: not inline\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10227,7 +10297,37 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class Y> template<>\n"); //$NON-NLS-1$
buffer.append("void A<Y>::B<double>::mf2() { }; // illformed; B<double> is specialized but\n"); //$NON-NLS-1$
buffer.append("// its enclosing class template A is not\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
+ }
+
+ /**
+ [--Start Example(CPP 14.8-2):
+ template<class T> void f(T* p)
+ {
+ static T s;
+ // ...
+ };
+ void g(int a, char* b)
+ {
+ f(&a); //call f<int>(int*)
+ f(&b); //call f<char*>(char**)
+ }
+ --End Example]
+ */
+ public void test14_8s2() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T* p)\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("static T s;\n"); //$NON-NLS-1$
+ buffer.append("// ...\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("void g(int a, char* b)\n"); //$NON-NLS-1$
+ buffer.append("{\n"); //$NON-NLS-1$
+ buffer.append("f(&a); //call f<int>(int*)\n"); //$NON-NLS-1$
+ buffer.append("f(&b); //call f<char*>(char**)\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10260,7 +10360,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i = convert<int,double>(d); // int convert(double)\n"); //$NON-NLS-1$
buffer.append("char c = convert<char,double>(d); // char convert(double)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10281,7 +10381,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i = f<int>(5.6); // Y is deduced to be double\n"); //$NON-NLS-1$
buffer.append("int j = f(5.6); // illformed: X cannot be deduced\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10308,7 +10408,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// Z is deduced to be double\n"); //$NON-NLS-1$
buffer.append("f(\"aa\",3.0); //error: X cannot be deduced\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10349,7 +10449,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f<3>(b); //wellformed because C::f is visible; then\n"); //$NON-NLS-1$
buffer.append("// A::f is found by argument dependent lookup\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10378,7 +10478,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int i = convert<int>(d); // call convert<int,double>(double)\n"); //$NON-NLS-1$
buffer.append("int c = convert<char>(d); // call convert<char,double>(double)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10393,7 +10493,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template <class T> int f(T[5]);\n"); //$NON-NLS-1$
buffer.append("int I = f<int>(0);\n"); //$NON-NLS-1$
buffer.append("int j = f<void>(0); // invalid array\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10406,7 +10506,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template <class T> int f(int T::*);\n"); //$NON-NLS-1$
buffer.append("int i = f<int>(0);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 2);
}
/**
@@ -10419,7 +10519,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("template <class T, T*> int f(int);\n"); //$NON-NLS-1$
buffer.append("int i2 = f<int,1>(0); // can’t conv 1 to int*\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 1);
}
/**
@@ -10436,7 +10536,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template <signed char> int f(int);\n"); //$NON-NLS-1$
buffer.append("int i1 = f<1>(0); // ambiguous\n"); //$NON-NLS-1$
buffer.append("int i2 = f<1000>(0); // ambiguous\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10465,7 +10565,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(a,a); //OK: T is A\n"); //$NON-NLS-1$
buffer.append("f(b,b); //OK: T is B\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10494,7 +10594,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(g2); //error: T could be char or int\n"); //$NON-NLS-1$
buffer.append("f(g3); //error: U could be char or float\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10515,7 +10615,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(v); //error: argument for templateparameter\n"); //$NON-NLS-1$
buffer.append("//T cannot be deduced\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10548,7 +10648,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f2<10>(v); //OK\n"); //$NON-NLS-1$
buffer.append("f3(v); //OK: i deduced to be 10\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10583,7 +10683,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B<1> b;\n"); //$NON-NLS-1$
buffer.append("g(b); //OK: cvqualifiers are ignored on template parameter types\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10616,7 +10716,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(&h); //OK: void h(char,int) is a unique match\n"); //$NON-NLS-1$
buffer.append("f(&foo); //error: type deduction fails because foo is a template\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10639,7 +10739,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(); //error: cannot deduce T\n"); //$NON-NLS-1$
buffer.append("f<int>(); //OK: call f<int>(5,7)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10662,7 +10762,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("char m2 = max(c,d); // max(char a, char b)\n"); //$NON-NLS-1$
buffer.append("int m3 = max(a,c); // error: cannot generate max(int,char)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -10687,7 +10787,27 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("char m2 = max(c,d); // max(char a, char b)\n"); //$NON-NLS-1$
buffer.append("int m3 = max(a,c); // resolved\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
+ }
+
+
+ /**
+ [--Start Example(CPP 14.8.3-6):
+ template<class T> void f(T); // declaration
+ void g()
+ {
+ f("Annemarie"); // call of f<const char*>
+ }
+ --End Example]
+ */
+ public void test14_8_3s6() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T); // declaration \n"); //$NON-NLS-1$
+ buffer.append("void g() { \n"); //$NON-NLS-1$
+ buffer.append(" f(\"Annemarie\"); // call of f<const char*> \n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10720,7 +10840,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("} catch(...) { // handler 1\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10765,7 +10885,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// handles exceptions thrown from the ctorinitializer\n"); //$NON-NLS-1$
buffer.append("// and from the constructor function body\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10814,7 +10934,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// handle exceptions of type Overflow here\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10843,7 +10963,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// other handler\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10882,7 +11002,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10897,7 +11017,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f() throw(int); // OK\n"); //$NON-NLS-1$
buffer.append("void (*fp)() throw (int); // OK\n"); //$NON-NLS-1$
buffer.append("void g(void pfa() throw(int)); // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10908,7 +11028,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test15_4s1b() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("typedef int (*pf)() throw(int); // illformed\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10933,7 +11053,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("void f(); // illformed\n"); //$NON-NLS-1$
buffer.append("void g() throw (int); // OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10958,7 +11078,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("pf1 = pf2; // OK: pf1 is less restrictive\n"); //$NON-NLS-1$
buffer.append("pf2 = pf1; // error: pf2 is more restrictive\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -10989,7 +11109,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("if (n) throw Z(); // also OK\n"); //$NON-NLS-1$
buffer.append("throw W(); // will call unexpected()\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11008,7 +11128,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("// f(); //OK\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11047,7 +11167,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// Implicit declaration of D::D(const D&) throw();\n"); //$NON-NLS-1$
buffer.append("// Implicit declaration of D::~D() throw (X,Y);\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11070,7 +11190,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("#else\n"); //$NON-NLS-1$
buffer.append("#define INCFILE \"versN.h\"\n"); //$NON-NLS-1$
buffer.append("#endif\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
// second pass of C++ spec is to get [Note: ]
@@ -11097,7 +11217,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("a = ((a + 32765) + b);\n"); //$NON-NLS-1$
buffer.append("a = (a + (b + 32765));\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11114,7 +11234,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("enum E { z = 16 };\n"); //$NON-NLS-1$
buffer.append("int b[X::z]; // OK\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11139,7 +11259,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("f(a);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11176,7 +11296,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("F f;\n"); //$NON-NLS-1$
buffer.append("f.A::a = 1; // OK, A::a is a member of F\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11197,7 +11317,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("// may be statically initialized to 0.0 or\n"); //$NON-NLS-1$
buffer.append("// dynamically initialized to 1.0\n"); //$NON-NLS-1$
buffer.append("double d1 = fd(); // may be initialized statically to 1.0\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11220,7 +11340,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("*pcc = &c;\n"); //$NON-NLS-1$
buffer.append("*pc = 'C'; //2: modifies a const object\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11245,7 +11365,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int S::* pm = &S::i; // pm refers to mutable member S::i\n"); //$NON-NLS-1$
buffer.append("cs.*pm = 88; // illformed: cs is a const object\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11288,7 +11408,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("g(); //okay: name g refers to the same entity\n"); //$NON-NLS-1$
buffer.append("h(); //error: name h found in two namespaces\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11305,7 +11425,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("//printf(\"a = %d\",a);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11320,7 +11440,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int a;\n"); //$NON-NLS-1$
buffer.append("const int b = a;\n"); //$NON-NLS-1$
buffer.append("int c = b;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11347,7 +11467,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("struct D2 : D {\n"); //$NON-NLS-1$
buffer.append("void f();\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11380,7 +11500,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B* bp = new D;\n"); //$NON-NLS-1$
buffer.append("delete bp; //1: uses D::operator delete(void*)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11417,7 +11537,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B* bp = new D[i];\n"); //$NON-NLS-1$
buffer.append("delete[] bp; // undefined behavior\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11448,7 +11568,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("operator+ (a,a); // ERROR - global operator hidden by member\n"); //$NON-NLS-1$
buffer.append("a + a; // OK - calls global operator+\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11471,7 +11591,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("C<V> value;\n"); //$NON-NLS-1$
buffer.append("// ...\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11494,7 +11614,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("T t1 = i; // templateparameters T and i\n"); //$NON-NLS-1$
buffer.append("::T t2 = ::i; // global namespace members T and i\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11517,7 +11637,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X<&s.m> x4; // error: address of nonstatic member\n"); //$NON-NLS-1$
buffer.append("X<&s.s> x5; // error: &S::s must be used\n"); //$NON-NLS-1$
buffer.append("X<&S::s> x6; // OK: address of static member\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11542,7 +11662,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("X<int,\"Studebaker\"> x1; // error: string literal as template argument\n"); //$NON-NLS-1$
buffer.append("char p[] = \"Vivisectionist\";\n"); //$NON-NLS-1$
buffer.append("X<int,p> x2; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11559,7 +11679,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("B<1> b2; // error: temporary would be required for template argument\n"); //$NON-NLS-1$
buffer.append("int c = 1;\n"); //$NON-NLS-1$
buffer.append("B<c> b1; // OK\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
}
/**
@@ -11570,7 +11690,35 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
public void test14_5_4s5() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("template<class T1, class T2, int I> class A<T1, T2, I> { }; // error\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, false, false);
+ parse(buffer.toString(), ParserLanguage.CPP, false, 0);
+ }
+
+ /**
+ [--Start Example(CPP 14.5.4-6):
+ template<class T> struct A {
+ class C {
+ template<class T2> struct B { };
+ };
+ };
+ // partial specialization of A<T>::C::B<T2>
+ template<class T> template<class T2>
+ struct A<T>::C::B<T2*> { };
+ A<short>::C::B<int*> absip; // uses partial specialization
+ --End Example]
+ */
+ public void test14_5_4s6() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> struct A {\n"); //$NON-NLS-1$
+ buffer.append("class C {\n"); //$NON-NLS-1$
+ buffer.append("template<class T2> struct B { };\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("};\n"); //$NON-NLS-1$
+ buffer.append("// partial specialization of A<T>::C::B<T2>\n"); //$NON-NLS-1$
+ buffer.append("template<class T> template<class T2>\n"); //$NON-NLS-1$
+ buffer.append("struct A<T>::C::B<T2*> { };\n"); //$NON-NLS-1$
+ buffer.append("A<short>::C::B<int*> absip; // uses partial specialization\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11585,7 +11733,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("template<class T> void f();\n"); //$NON-NLS-1$
buffer.append("template<int I> void f(); // OK: overloads the first template\n"); //$NON-NLS-1$
buffer.append("// distinguishable with an explicit template argument list\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11602,34 +11750,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
buffer.append("int f(int); // #2\n"); //$NON-NLS-1$
buffer.append("int k = f(1); // uses #2\n"); //$NON-NLS-1$
buffer.append("int l = f<>(1); // uses #1\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
- }
-
- /**
- [--Start Example(CPP 14.8.1-4):
- template<class T> void f(T);
- class Complex {
- // ...
- Complex(double);
- };
- void g()
- {
- f<Complex>(1); // OK, means f<Complex>(Complex(1))
- }
- --End Example]
- */
- public void test14_8_1s4() throws Exception {
- StringBuffer buffer = new StringBuffer();
- buffer.append("template<class T> void f(T);\n"); //$NON-NLS-1$
- buffer.append("class Complex {\n"); //$NON-NLS-1$
- buffer.append("// ...\n"); //$NON-NLS-1$
- buffer.append("Complex(double);\n"); //$NON-NLS-1$
- buffer.append("};\n"); //$NON-NLS-1$
- buffer.append("void g()\n"); //$NON-NLS-1$
- buffer.append("{\n"); //$NON-NLS-1$
- buffer.append("f<Complex>(1); // OK, means f<Complex>(Complex(1))\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
/**
@@ -11642,7 +11763,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("#define TABSIZE 100\n"); //$NON-NLS-1$
buffer.append("int table[TABSIZE];\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.CPP, true, true);
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java
index 3575ce73155..d4dabaf1efa 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecFailingTest.java
@@ -56,7 +56,7 @@ public class AST2CSpecFailingTest extends AST2SpecBaseTest {
buffer.append("xglue(HIGH, LOW)\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
assertTrue(false);
} catch (Exception e) {}
}
@@ -104,7 +104,7 @@ public class AST2CSpecFailingTest extends AST2SpecBaseTest {
buffer.append("char c[2][6] = { str(hello), str() };\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
assertTrue(false);
} catch (Exception e) {}
}
@@ -122,7 +122,7 @@ public class AST2CSpecFailingTest extends AST2SpecBaseTest {
buffer.append("int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,),\n"); //$NON-NLS-1$
buffer.append("t(10,,), t(,11,), t(,,12), t(,,) };\n"); //$NON-NLS-1$
try {
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
assertTrue(false);
} catch (Exception e) {}
}
@@ -154,7 +154,7 @@ public class AST2CSpecFailingTest extends AST2SpecBaseTest {
buffer.append("report(x>y, \"x is %d but y is %d\", x, y);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
try {
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
assertTrue(false);
} catch (Exception e) {}
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
index c976d8be32a..c40207f5725 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java
@@ -29,7 +29,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("#ifdef _ _STDC_IEC_559_ _ /* FE_UPWARD defined */\n"); //$NON-NLS-1$
buffer.append("fesetround(FE_UPWARD);\n"); //$NON-NLS-1$
buffer.append("#endif\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -42,7 +42,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("char i;\n"); //$NON-NLS-1$
buffer.append("int i;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -59,7 +59,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("char c1, c2;\n"); //$NON-NLS-1$
buffer.append("c1 = c1 + c2;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -78,7 +78,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("double d;\n"); //$NON-NLS-1$
buffer.append("f1 = f2 * d;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -99,7 +99,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("d1 = f = 1;\n"); //$NON-NLS-1$
buffer.append("d2 = (float) 1;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -122,7 +122,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("z = x + x * y; // not equivalent toz = x * (1.0 + y);\n"); //$NON-NLS-1$
buffer.append("y = x / 5.0; // not equivalent toy = x * 0.2;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -147,7 +147,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("a = ((a + 32765) + b);\n"); //$NON-NLS-1$
buffer.append("a = (a + (b + 32765));\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -168,7 +168,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("char *p;\n"); //$NON-NLS-1$
buffer.append("sum = sum * 10 - '0' + (*p++ = getchar());\n"); //$NON-NLS-1$
buffer.append("sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -179,7 +179,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_2_5s28() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct tag (* a[5])(float);\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -194,7 +194,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int f(int (*)(), double (*)[3]);\n"); //$NON-NLS-1$
buffer.append("int f(int (*)(char *), double (*)[]);\n"); //$NON-NLS-1$
buffer.append("int f(int (*)(char *), double (*)[3]);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -209,7 +209,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("char x='\\023';\n"); //$NON-NLS-1$
buffer.append("char y='\\0';\n"); //$NON-NLS-1$
buffer.append("char z='\\x13';\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -234,7 +234,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int foo() {\n"); //$NON-NLS-1$
buffer.append("int x=(*pf[f1()]) (f2(), f3() + f4());\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -267,7 +267,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("vs.i; // volatile int\n"); //$NON-NLS-1$
buffer.append("vs.ci; // volatile const int\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -318,7 +318,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("if (sin(u.nf.doublenode) == 0.0)\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -359,7 +359,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("} u;\n"); //$NON-NLS-1$
buffer.append("return f(&u.s1, &u.s2);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -370,7 +370,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_5_2_5s9() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int *p = (int []){2, 4};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -389,7 +389,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int *p;\n"); //$NON-NLS-1$
buffer.append("p = (int [2]){*p};\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -410,7 +410,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("drawline(&(struct point){.x=1, .y=1},\n"); //$NON-NLS-1$
buffer.append("&(struct point){.x=3, .y=4});\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, false, false);
+ parse(buffer.toString(), ParserLanguage.C, false, 0);
}
/**
@@ -425,7 +425,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int f() {\n"); //$NON-NLS-1$
buffer.append("(const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6};\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -444,7 +444,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("(char []){\"/tmp/fileXXXXXX\"};\n"); //$NON-NLS-1$
buffer.append("(const char []){\"/tmp/fileXXXXXX\"};\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -459,7 +459,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int f() {\n"); //$NON-NLS-1$
buffer.append("(const char []){\"abc\"} == \"abc\";\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -478,7 +478,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("struct int_list endless_zeros = {0, &endless_zeros};\n"); //$NON-NLS-1$
buffer.append("eval(endless_zeros);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -507,7 +507,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("if (j < 2) goto again;\n"); //$NON-NLS-1$
buffer.append("return p == q && q->i == 1;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -520,7 +520,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("extern void *alloc(size_t);\n"); //$NON-NLS-1$
buffer.append("double *dp = alloc(sizeof *dp);\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -537,7 +537,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int array[5];\n"); //$NON-NLS-1$
buffer.append("int x = sizeof array / sizeof array[0];\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -562,7 +562,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("(*p)[2] = 99; // a[1][2] == 99\n"); //$NON-NLS-1$
buffer.append("n = p - a; // n == 1\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -587,7 +587,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int *ip;\n"); //$NON-NLS-1$
buffer.append("const char *c_cp;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -608,7 +608,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("long l;\n"); //$NON-NLS-1$
buffer.append("l = (c = i);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -633,7 +633,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("*cpp = &c; // valid\n"); //$NON-NLS-1$
buffer.append("*p = 0; // valid\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -656,7 +656,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("offsetof(struct s, d);\n"); //$NON-NLS-1$
buffer.append("offsetof(struct ss, d);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -677,7 +677,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("s1 = malloc(sizeof (struct s) + 64);\n"); //$NON-NLS-1$
buffer.append("s2 = malloc(sizeof (struct s) + 46);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -690,7 +690,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("struct { int n; double d[8]; } *s1;\n"); //$NON-NLS-1$
buffer.append("struct { int n; double d[5]; } *s2;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -715,7 +715,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("if (*cp != burgundy)\n"); //$NON-NLS-1$
buffer.append("return 0;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -734,7 +734,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("struct tnode *left, *right;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("struct tnode s, *sp;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -755,7 +755,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("TNODE *left, *right;\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("TNODE s, *sp;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -770,7 +770,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("struct s2;\n"); //$NON-NLS-1$
buffer.append("struct s1 { struct s2 *s2p; }; // D1\n"); //$NON-NLS-1$
buffer.append("struct s2 { struct s1 *s1p; }; // D2\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -781,7 +781,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_3s10() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("extern const volatile int real_time_clock;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -818,7 +818,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("pci = &cs.mem; // valid\n"); //$NON-NLS-1$
buffer.append("pi = a[0]; // invalid: a[0] has type ‘‘const int *’’\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -833,7 +833,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int * restrict a;\n"); //$NON-NLS-1$
buffer.append("int * restrict b;\n"); //$NON-NLS-1$
buffer.append("extern int c[];\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -852,7 +852,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("while (n-- > 0)\n"); //$NON-NLS-1$
buffer.append("*p++ = *q++;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -883,7 +883,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("f(50, d + 50, d); // valid\n"); //$NON-NLS-1$
buffer.append("f(50, d + 1, d); // undefined behavior\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -904,7 +904,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("for (i = 0; i < n; i++)\n"); //$NON-NLS-1$
buffer.append("p[i] = q[i] + r[i];\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -937,7 +937,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("p2 = q2; // undefined behavior\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -962,7 +962,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("t.v = malloc(n * sizeof (float));\n"); //$NON-NLS-1$
buffer.append("return t;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, false, false);
+ parse(buffer.toString(), ParserLanguage.C, false, 0);
}
/**
@@ -997,7 +997,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("return is_fahr ? cels(temp) : fahr(temp);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1014,7 +1014,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int *const constant_ptr1;\n"); //$NON-NLS-1$
buffer.append("typedef int *int_ptr;\n"); //$NON-NLS-1$
buffer.append("const int_ptr constant_ptr2;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1025,7 +1025,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_5_2s7() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("float fa[11], *afp[17];\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1038,7 +1038,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("extern int *x;\n"); //$NON-NLS-1$
buffer.append("extern int y[];\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1071,7 +1071,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("r = c; // compatible, but defined behavior only if\n"); //$NON-NLS-1$
buffer.append("// n == 6 andm == n+1\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, false, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1118,7 +1118,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("extern int (*r)[m]; // invalid: r has linkage and points to VLA\n"); //$NON-NLS-1$
buffer.append("static int (*q)[m] = &B; // valid: q is a static block pointer to VLA\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1129,7 +1129,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_5_3s16() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int f(void), *fip(), (*pfi)();\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1140,7 +1140,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_5_3s18() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int (*apfi[3])(int *x, int *y);\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1151,7 +1151,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_5_3s19() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int (*fpfi(int (*)(long), int))(int, ...);\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1192,7 +1192,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("// a is a pointer to a VLA with n*m+300 elements\n"); //$NON-NLS-1$
buffer.append("a[i][j] += x;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1217,7 +1217,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("void f2(double a[restrict][5]);\n"); //$NON-NLS-1$
buffer.append("void f3(double a[restrict 3][5]);\n"); //$NON-NLS-1$
buffer.append("void f4(double a[restrict static 3][5]);\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1238,7 +1238,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("extern KLICKSP *metricp;\n"); //$NON-NLS-1$
buffer.append("range x;\n"); //$NON-NLS-1$
buffer.append("range z, *zp;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1251,7 +1251,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("typedef struct s1 { int x; } t1, *tp1;\n"); //$NON-NLS-1$
buffer.append("typedef struct s2 { int x; } t2, *tp2;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1278,7 +1278,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("};\n"); //$NON-NLS-1$
buffer.append("t f(t (t));\n"); //$NON-NLS-1$
buffer.append("long t;\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1295,7 +1295,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("void (*signal(int, void (*)(int)))(int);\n"); //$NON-NLS-1$
buffer.append("fv *signal(int, fv *);\n"); //$NON-NLS-1$
buffer.append("pfv signal(int, pfv);\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1322,7 +1322,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("for (int i = 1; i < n; i++)\n"); //$NON-NLS-1$
buffer.append("a[i-1] = b[i];\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1335,7 +1335,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("int i = 3.5;\n"); //$NON-NLS-1$
buffer.append("complex c = 5 + 3 * I;\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -1346,7 +1346,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_8s25() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("int x[] = { 1, 3, 5 };\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1365,7 +1365,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("{ 2, 4, 6 },\n"); //$NON-NLS-1$
buffer.append("{ 3, 5, 7 },\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1380,7 +1380,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int y[4][3] = {\n"); //$NON-NLS-1$
buffer.append("1, 3, 5, 2, 4, 6, 3, 5, 7\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1395,7 +1395,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int z[4][3] = {\n"); //$NON-NLS-1$
buffer.append("{ 1 }, { 2 }, { 3 }, { 4 }\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1406,7 +1406,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_8s28() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct { int a[3], b; } w[] = { { 1 }, 2 };\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1459,7 +1459,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("{ 6 },\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1474,7 +1474,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("typedef int A[]; // OK - declared with block scope\n"); //$NON-NLS-1$
buffer.append("A a1 = { 1, 2 }, b1 = { 3, 4, 5 };\n"); //$NON-NLS-1$
buffer.append("int a2[] = { 1, 2 }, b2[] = { 3, 4, 5 };\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1495,7 +1495,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("t2[] = { 'a', 'b', 'c' };\n"); //$NON-NLS-1$
buffer.append("char *p = \"abc\";\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1514,7 +1514,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("[member_two] = \"member two\",\n"); //$NON-NLS-1$
buffer.append("[member_one] = \"member one\",\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1525,7 +1525,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_8s34() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("div_t answer = { .quot = 2, .rem = -1 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1538,7 +1538,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("struct { int a[3], b; } w[] =\n"); //$NON-NLS-1$
buffer.append("{ [0].a = {1}, [1].a[0] = 2 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1555,7 +1555,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int a[MAX] = {\n"); //$NON-NLS-1$
buffer.append("1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0\n"); //$NON-NLS-1$
buffer.append("};\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1566,7 +1566,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_7_8s38() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("union { int any_member; } u = { .any_member = 42 };\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1583,7 +1583,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int f() {\n"); //$NON-NLS-1$
buffer.append("(void)p(0);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1602,7 +1602,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("while (*s++ != '\0')\n"); //$NON-NLS-1$
buffer.append(";\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1633,7 +1633,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("end_loop1: ;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1666,7 +1666,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("f(i+1);\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1701,7 +1701,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("// handle other operations\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1738,7 +1738,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("}\n"); //$NON-NLS-1$
buffer.append("goto lab4; // invalid: going INTO scope of VLA.\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), false, false);
+ parseCandCPP(buffer.toString(), false, 0);
}
/**
@@ -1783,7 +1783,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("int foo() {\n"); //$NON-NLS-1$
buffer.append("g.u2.f3 = f();\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parse(buffer.toString(), ParserLanguage.C, true, true);
+ parse(buffer.toString(), ParserLanguage.C, true, 0);
}
/**
@@ -1800,7 +1800,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("{\n"); //$NON-NLS-1$
buffer.append("return a > b ? a : b;\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1819,7 +1819,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("(*funcp)();\n"); //$NON-NLS-1$
buffer.append("funcp();\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1858,7 +1858,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("extern int i3; // refers to pre vious, whose linkage is external\n"); //$NON-NLS-1$
buffer.append("extern int i4; // refers to pre vious, whose linkage is external\n"); //$NON-NLS-1$
buffer.append("extern int i5; // refers to pre vious, whose linkage is internal\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1883,7 +1883,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("if ('z' - 'a' == 25)\n"); //$NON-NLS-1$
buffer.append("g();\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1904,7 +1904,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("#define join(c, d) in_between(c hash_hash d)\n"); //$NON-NLS-1$
buffer.append("char p[] = join(x, y); // equivalent to\n"); //$NON-NLS-1$
buffer.append("// char p[] = \"x ## y\";\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1917,7 +1917,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
StringBuffer buffer = new StringBuffer();
buffer.append("#define TABSIZE 100\n"); //$NON-NLS-1$
buffer.append("int table[TABSIZE];\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1928,7 +1928,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test6_10_3_5s4() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("#define max(a, b) ((a) > (b) ? (a) : (b))\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
/**
@@ -1951,7 +1951,7 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
buffer.append("#define FUNC_LIKE2( a )( \\n"); //$NON-NLS-1$
buffer.append(" a \\n"); //$NON-NLS-1$
buffer.append(" )\n"); //$NON-NLS-1$
- parseCandCPP(buffer.toString(), true, true);
+ parseCandCPP(buffer.toString(), true, 0);
}
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java
index 0945ab036fc..951405814f9 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecBaseTest.java
@@ -56,26 +56,25 @@ public class AST2SpecBaseTest extends TestCase {
* checkSemantics is used to specify whether the example should have semantics checked
* since several spec examples have syntactically correct code ONLY this flag was added
* so that future tests can ensure that examples are checked against syntax/semantics where necessary
- *
* @param code
- * @param checkSemantics
+ * @param expectedProblemBindings the number of problem bindings you expect to encounter
* @throws ParserException
*/
- protected void parseCandCPP( String code, boolean checkSemantics, boolean checkBindings ) throws ParserException {
- parse( code, ParserLanguage.C, false, true, checkSemantics, checkBindings);
- parse( code, ParserLanguage.CPP, false, true, checkSemantics, checkBindings );
+ protected void parseCandCPP( String code, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
+ parse( code, ParserLanguage.C, false, true, checkBindings, expectedProblemBindings);
+ parse( code, ParserLanguage.CPP, false, true, checkBindings, expectedProblemBindings );
}
- protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkSemantics, boolean checkBindings ) throws ParserException {
- return parse(code, lang, false, true, checkSemantics, checkBindings );
+ protected IASTTranslationUnit parse( String code, ParserLanguage lang, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
+ return parse(code, lang, false, true, checkBindings, expectedProblemBindings );
}
- private IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean checkSemantics, boolean checkBindings ) throws ParserException {
+ private IASTTranslationUnit parse( String code, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings ) throws ParserException {
// TODO beef this up with tests... i.e. run once with \n, and then run again with \r\n replacing \n ... etc
// TODO another example might be to replace all characters with corresponding trigraph/digraph tests...
CodeReader codeReader = new CodeReader(code.toCharArray());
- return parse(codeReader, lang, useGNUExtensions, expectNoProblems, checkSemantics, checkBindings);
+ return parse(codeReader, lang, useGNUExtensions, expectNoProblems, checkBindings, expectedProblemBindings);
}
// private IASTTranslationUnit parse( IFile filename, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems ) throws ParserException {
@@ -91,7 +90,7 @@ public class AST2SpecBaseTest extends TestCase {
// return parse(codeReader, lang, useGNUExtensions, expectNoProblems);
// }
- private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean checkSemantics, boolean checkBindings) throws ParserException {
+ private IASTTranslationUnit parse(CodeReader codeReader, ParserLanguage lang, boolean useGNUExtensions, boolean expectNoProblems, boolean checkBindings, int expectedProblemBindings) throws ParserException {
ScannerInfo scannerInfo = new ScannerInfo();
IScannerExtensionConfiguration configuration = null;
if( lang == ParserLanguage.C )
@@ -132,13 +131,13 @@ public class AST2SpecBaseTest extends TestCase {
if ( lang == ParserLanguage.CPP ) {
CPPNameResolver res = new CPPNameResolver();
tu.accept( res );
- if (res.foundProblemBinding)
- throw new ParserException("found IProblemBinding"); //$NON-NLS-1$
+ if (res.numProblemBindings != expectedProblemBindings )
+ throw new ParserException("Expected " + expectedProblemBindings + " problems, encountered " + res.numProblemBindings ); //$NON-NLS-1$ //$NON-NLS-2$
} else if (lang == ParserLanguage.C ) {
CNameResolver res = new CNameResolver();
tu.accept( res );
- if (res.foundProblemBinding)
- throw new ParserException("found IProblemBinding"); //$NON-NLS-1$
+ if (res.numProblemBindings != expectedProblemBindings )
+ throw new ParserException("Expected " + expectedProblemBindings + " problems, encountered " + res.numProblemBindings ); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -171,12 +170,13 @@ public class AST2SpecBaseTest extends TestCase {
{
shouldVisitNames = true;
}
- public boolean foundProblemBinding=false;
+ public int numProblemBindings=0;
public List nameList = new ArrayList();
public int visit( IASTName name ){
+ nameList.add( name );
IBinding binding = name.resolveBinding();
if (binding instanceof IProblemBinding)
- foundProblemBinding=true;
+ numProblemBindings++;
return PROCESS_CONTINUE;
}
public IASTName getName( int idx ){
@@ -191,12 +191,13 @@ public class AST2SpecBaseTest extends TestCase {
{
shouldVisitNames = true;
}
- public boolean foundProblemBinding=false;
+ public int numProblemBindings=0;
public List nameList = new ArrayList();
public int visit( IASTName name ){
+ nameList.add( name );
IBinding binding = name.resolveBinding();
if (binding instanceof IProblemBinding)
- foundProblemBinding=true;
+ numProblemBindings++;
return PROCESS_CONTINUE;
}
public IASTName getName( int idx ){
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 c7efbf1562b..e4c01f4b16a 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
@@ -16,9 +16,11 @@ package org.eclipse.cdt.core.parser.tests.ast2;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IPointerType;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
@@ -29,9 +31,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.ParserLanguage;
@@ -277,8 +282,476 @@ public class AST2TemplateTests extends AST2BaseTest {
ICPPMethod f1 = (ICPPMethod) col.getName(2).resolveBinding();
ICPPMethod f2 = (ICPPMethod) col.getName(8).resolveBinding();
- //TODO this isn't right, but its close enough for now
+ assertSame( f2, f1 );
+ }
+
+ public void testTemplateFunctionImplicitInstantiation() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template < class T > void f ( T ); \n"); //$NON-NLS-1$
+ buffer.append("void main() { \n"); //$NON-NLS-1$
+ buffer.append(" f( 1 ); \n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f1 );
}
+
+ /**
+ * template< class T > void f( T ); //#1
+ * template< class T > void f( T* ); //#2
+ * template< class T > void f( const T* ); //#3
+ *
+ * const int *p;
+ * f( p ); //calls f( const T * ) , 3 is more specialized than 1 or 2
+ *
+ * @throws Exception
+ *
+ */
+ public void test_14_5_5_2s5_OrderingFunctionTemplates_1() throws Exception{
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "template < class T > void f( T ); \n"); //$NON-NLS-1$
+ buffer.append( "template < class T > void f( T* ); \n"); //$NON-NLS-1$
+ buffer.append( "template < class T > void f( const T* ); \n"); //$NON-NLS-1$
+ buffer.append( "void main() { \n"); //$NON-NLS-1$
+ buffer.append( " const int *p; \n"); //$NON-NLS-1$
+ buffer.append( " f( p ); \n"); //$NON-NLS-1$
+ buffer.append( "} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f3 );
+ }
+
+ /**
+ * template< class T > void g( T ); //#1
+ * template< class T > void g( T& ); //#2
+
+ * float x;
+ * g( x ); //ambiguous 1 or 2
+ *
+ * @throws Exception
+ */
+ public void test_14_5_5_2s5_OrderingFunctionTemplates_2() throws Exception{
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "template < class T > void f( T ); \n"); //$NON-NLS-1$
+ buffer.append( "template < class T > void f( T& ); \n"); //$NON-NLS-1$
+ buffer.append( "void main() { \n"); //$NON-NLS-1$
+ buffer.append( " float x; \n"); //$NON-NLS-1$
+ buffer.append( " f( x ); \n"); //$NON-NLS-1$
+ buffer.append( "} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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 );
+ }
+
+ public void testTemplateParameters() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "template < class T, template < class X > class U, T *pT > class A { \n"); //$NON-NLS-1$
+ buffer.append( "}; \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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 );
+ }
+
+ public void testDeferredInstances() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "template <class T> class A { \n"); //$NON-NLS-1$
+ buffer.append( " A<T>* a; \n"); //$NON-NLS-1$
+ buffer.append( " A<T>* a2; \n"); //$NON-NLS-1$
+ buffer.append( "}; \n"); //$NON-NLS-1$
+ buffer.append( "void f(){ \n"); //$NON-NLS-1$
+ buffer.append( " A<int> * b; \n"); //$NON-NLS-1$
+ buffer.append( " b->a; \n"); //$NON-NLS-1$
+ buffer.append( "} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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.getOriginalBinding(), 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 ICPPTemplateInstance );
+ assertSame( ((ICPPTemplateInstance)a2).getOriginalBinding(), a );
+ IType at = a2.getType();
+ assertTrue( at instanceof IPointerType );
+
+ assertSame( ((IPointerType)at).getType(), ((IPointerType)bt).getType() );
+ }
+
+ public void test_14_5_4_1s2_MatchingTemplateSpecializations() throws Exception{
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "template < class T1, class T2, int I > class A {}; //#1 \n"); //$NON-NLS-1$
+ buffer.append( "template < class T, int I > class A < T, T*, I > {}; //#2 \n"); //$NON-NLS-1$
+ buffer.append( "template < class T1, class T2, int I > class A < T1*, T2, I > {}; //#3 \n"); //$NON-NLS-1$
+ buffer.append( "template < class T > class A < int, T*, 5 > {}; //#4 \n"); //$NON-NLS-1$
+ buffer.append( "template < class T1, class T2, int I > class A < T1, T2*, I > {}; //#5 \n"); //$NON-NLS-1$
+
+ buffer.append( "A <int, int, 1> a1; //uses #1 \n"); //$NON-NLS-1$
+ buffer.append( "A <int, int*, 1> a2; //uses #2, T is int, I is 1 \n"); //$NON-NLS-1$
+ buffer.append( "A <int, char*, 5> a3; //uses #4, T is char \n"); //$NON-NLS-1$
+ buffer.append( "A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1 \n"); //$NON-NLS-1$
+ buffer.append( "A <int*, int*, 2> a5; //ambiguous, matches #3 & #5. \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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 ICPPTemplateSpecialization );
+ assertSame( ((ICPPTemplateSpecialization)A3).getPrimaryTemplateDefinition(), 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.getOriginalBinding(), A1 );
+ assertSame( R2.getOriginalBinding(), A2 );
+ assertSame( R4.getOriginalBinding(), A5 );
+ assertSame( R3.getOriginalBinding(), A4 );
+ }
+
+ public void test14_7_3_FunctionExplicitSpecialization() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template <class T> void f(T); \n"); //$NON-NLS-1$
+ buffer.append("template <class T> void f(T*); \n"); //$NON-NLS-1$
+ buffer.append("template <> void f(int); //ok \n"); //$NON-NLS-1$
+ buffer.append("template <> void f<int>(int*); // OK \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ CPPNameCollector col = new CPPNameCollector();
+ tu.accept( col );
+
+ ICPPFunctionTemplate fT1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
+ ICPPFunctionTemplate fT2 = (ICPPFunctionTemplate) col.getName(5).resolveBinding();
+
+ ICPPTemplateSpecialization f1 = (ICPPTemplateSpecialization) col.getName(8).resolveBinding();
+ ICPPTemplateSpecialization f2 = (ICPPTemplateSpecialization) col.getName(10).resolveBinding();
+
+ assertFalse( f1.isPartialSpecialization() );
+ assertFalse( f2.isPartialSpecialization() );
+
+ assertSame( f1.getPrimaryTemplateDefinition(), fT1 );
+ assertSame( f2.getPrimaryTemplateDefinition(), fT2 );
+ }
+
+ public void test_14_5_5_1_FunctionTemplates_1() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T*); \n"); //$NON-NLS-1$
+ buffer.append("void g(int* p) { f(p); } \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f );
+ }
+
+ public void test_14_5_5_1_FunctionTemplates_2() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T); \n"); //$NON-NLS-1$
+ buffer.append("void g(int* p) { f(p); } \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f );
+ }
+
+ public void test_14_8_1s2_FunctionTemplates() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class X, class Y> X f(Y); \n"); //$NON-NLS-1$
+ buffer.append("void g(){ \n"); //$NON-NLS-1$
+ buffer.append(" int i = f<int>(5); // Y is int \n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f );
+ }
+
+ public void test14_8_3s6_FunctionTemplates() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T); \n"); //$NON-NLS-1$
+ buffer.append("void g(){ \n"); //$NON-NLS-1$
+ buffer.append(" f(\"Annemarie\"); \n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f );
+ }
+
+ public void test14_5_5_2s6_FunctionTemplates() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T); // #1\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void f(T*, int=1); // #2\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void g(T); // #3\n"); //$NON-NLS-1$
+ buffer.append("template<class T> void g(T*, ...); // #4\n"); //$NON-NLS-1$
+ buffer.append("int main() { \n"); //$NON-NLS-1$
+ buffer.append(" int* ip; \n"); //$NON-NLS-1$
+ buffer.append(" f(ip); //calls #2\n"); //$NON-NLS-1$
+ buffer.append(" g(ip); //calls #4\n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f2 );
+
+ assertTrue( ref2 instanceof ICPPTemplateInstance );
+ assertSame( ((ICPPTemplateInstance) ref2).getOriginalBinding(), g2 );
+ }
+
+ public void test14_6_1s1_LocalNames() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> class X { \n"); //$NON-NLS-1$
+ buffer.append(" X* p; // meaning X<T>\n"); //$NON-NLS-1$
+ buffer.append(" X<T>* p2; \n"); //$NON-NLS-1$
+ buffer.append("}; \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), X );
+
+ assertSame( x1, x2 );
+ }
+
+ public void test14_8s2_() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> T f(T* p){ \n"); //$NON-NLS-1$
+ buffer.append("}; \n"); //$NON-NLS-1$
+ buffer.append("void g(int a, char* b){ \n"); //$NON-NLS-1$
+ buffer.append(" f(&a); //call f<int>(int*) \n"); //$NON-NLS-1$
+ buffer.append(" f(&b); //call f<char*>(char**)\n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), f );
+ assertTrue( f2 instanceof ICPPTemplateInstance );
+ assertSame( ((ICPPTemplateInstance)f2).getOriginalBinding(), f );
+
+ IType fr1 = f1.getType().getReturnType();
+ IType fr2 = f2.getType().getReturnType();
+
+ assertTrue( fr1 instanceof IBasicType );
+ 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 );
+ }
+
+ public void test14_7_3s14() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> void f(T) { } \n"); //$NON-NLS-1$
+ buffer.append("template<class T> inline T g(T) { } \n"); //$NON-NLS-1$
+ buffer.append("template<> inline void f<>(int) { } //OK: inline \n"); //$NON-NLS-1$
+ buffer.append("template<> int g<>(int) { } // OK: not inline\n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ CPPNameCollector col = new CPPNameCollector();
+ tu.accept( col );
+
+ ICPPFunctionTemplate f1 = (ICPPFunctionTemplate) col.getName(1).resolveBinding();
+ ICPPFunctionTemplate g1 = (ICPPFunctionTemplate) col.getName(6).resolveBinding();
+
+ ICPPTemplateSpecialization f2 = (ICPPTemplateSpecialization) col.getName(9).resolveBinding();
+ ICPPTemplateSpecialization g2 = (ICPPTemplateSpecialization) col.getName(12).resolveBinding();
+
+ assertFalse( ((ICPPFunction)f1).isInline() );
+ assertTrue( ((ICPPFunction)g1).isInline() );
+ assertTrue( ((ICPPFunction)f2).isInline() );
+ assertFalse( ((ICPPFunction)g2).isInline() );
+ }
+
+ public void test14_7_1s14_InfiniteInstantiation() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> class X { \n"); //$NON-NLS-1$
+ buffer.append(" X<T*> a; // implicit generation of X<T> requires \n"); //$NON-NLS-1$
+ buffer.append(" // the implicit instantiation of X<T*> which requires \n"); //$NON-NLS-1$
+ buffer.append(" // the implicit instantiation of X<T**> which ... \n"); //$NON-NLS-1$
+ buffer.append("}; \n"); //$NON-NLS-1$
+ buffer.append("void f() { \n"); //$NON-NLS-1$
+ buffer.append(" X<int> x; \n"); //$NON-NLS-1$
+ buffer.append(" x.a.a.a.a; \n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), 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).getOriginalBinding(), 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 ICPPTemplateInstance );
+ assertTrue( a2 instanceof ICPPTemplateInstance );
+ assertTrue( a3 instanceof ICPPTemplateInstance );
+ assertTrue( a4 instanceof ICPPTemplateInstance );
+ assertSame( ((ICPPTemplateInstance)a1).getOriginalBinding(), a );
+ assertSame( ((ICPPTemplateInstance)a2).getOriginalBinding(), a );
+ assertSame( ((ICPPTemplateInstance)a3).getOriginalBinding(), a );
+ assertSame( ((ICPPTemplateInstance)a4).getOriginalBinding(), a );
+ }
+
+ public void test14_6_1s2() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("template<class T> class Y; \n"); //$NON-NLS-1$
+ buffer.append("template<> class Y<int> { \n"); //$NON-NLS-1$
+ buffer.append(" Y* p; // meaning Y<int> \n"); //$NON-NLS-1$
+ buffer.append(" Y<char>* q; // meaning Y<char> \n"); //$NON-NLS-1$
+ buffer.append("}; \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
+ CPPNameCollector col = new CPPNameCollector();
+ tu.accept( col );
+
+ ICPPClassTemplate Y = (ICPPClassTemplate) col.getName(1).resolveBinding();
+ ICPPTemplateSpecialization Yspec = (ICPPTemplateSpecialization) col.getName(2).resolveBinding();
+
+ assertTrue( Yspec instanceof ICPPClassType );
+ assertSame( Yspec.getPrimaryTemplateDefinition(), Y );
+
+ ICPPClassType y1 = (ICPPClassType) col.getName(4).resolveBinding();
+ assertTrue( y1 instanceof ICPPTemplateInstance );
+ assertSame( ((ICPPTemplateInstance)y1).getOriginalBinding(), Yspec );
+
+ ICPPClassType y2 = (ICPPClassType) col.getName(6).resolveBinding();
+ assertTrue( y2 instanceof ICPPTemplateInstance );
+ assertSame( ((ICPPTemplateInstance)y2).getOriginalBinding(), Y );
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java
index 22ea7b42331..5c90e69b373 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
* @author Doug Schaefer
*/
public interface IASTNode {
-
+ public static final IASTNode [] EMPTY_NODE_ARRAY = new IASTNode[0];
/**
* Get the translation unit (master) node that is the ancestor of all nodes
* in this AST.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java
index 85c0d8248d1..5fcee0bed9c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IBasicType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -28,6 +28,14 @@ public interface IBasicType extends IType {
*/
public int getType() throws DOMException;
+ /**
+ * Returns the IASTExpression for the value of this type. May be null.
+ *
+ * @return IASTExpression or null
+ * @throws DOMException
+ */
+ public IASTExpression getValue() throws DOMException;
+
public static final int t_unspecified = IASTSimpleDeclSpecifier.t_unspecified;
public static final int t_void = IASTSimpleDeclSpecifier.t_void;
public static final int t_char = IASTSimpleDeclSpecifier.t_char;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java
new file mode 100644
index 00000000000..a2f81513786
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPParameter.java
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ **********************************************************************/
+/*
+ * Created on Apr 20, 2005
+ */
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+
+/**
+ * @author aniefer
+ *
+ */
+public interface ICPPParameter extends IParameter, ICPPVariable {
+
+ /**
+ * the default value of this parameter or null if there is none.
+ * @return
+ */
+ public IASTInitializer getDefaultValue();
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java
index 53c9885602c..9f09497d19b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateDefinition.java
@@ -10,6 +10,8 @@
**********************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+
/**
* @author Doug Schaefer
@@ -22,5 +24,7 @@ public interface ICPPTemplateDefinition extends ICPPBinding{
* a partial specialization will have the specialized parameter list
* @return array of ICPPTemplateParameter
*/
- public ICPPTemplateParameter[] getTemplateParameters();
+ public ICPPTemplateParameter[] getTemplateParameters() throws DOMException;
+
+ public ICPPTemplateSpecialization[] getTemplateSpecializations() throws DOMException;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java
index f939524a0bc..f13c764486f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java
@@ -14,6 +14,7 @@
package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
@@ -34,6 +35,8 @@ public interface ICPPTemplateInstance extends IBinding {
*/
public ObjectMap getArgumentMap();
+ public IType [] getArguments();
+
public ICPPTemplateDefinition getTemplate();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java
index 9670b28f549..eec50e82fbf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateParameter.java
@@ -15,5 +15,5 @@ package org.eclipse.cdt.core.dom.ast.cpp;
* @author Doug Schaefer
*/
public interface ICPPTemplateParameter extends ICPPBinding {
-
+ public static final ICPPTemplateParameter[] EMPTY_TEMPLATE_PARAMETER_ARRAY = new ICPPTemplateParameter[0];
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateSpecialization.java
index 39e6218a951..9a613556099 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateSpecialization.java
@@ -13,28 +13,29 @@
*/
package org.eclipse.cdt.core.dom.ast.cpp;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IType;
/**
* @author aniefer
*/
public interface ICPPTemplateSpecialization extends ICPPTemplateDefinition {
-
+ public static final ICPPTemplateSpecialization[] EMPTY_TEMPLATE_SPECIALIZATION_ARRAY = new ICPPTemplateSpecialization[0];
/**
* get the arguments to this specialization
* @return
*/
- public IASTNode [] getArguments();
+ public IType [] getArguments() throws DOMException;
/**
* is this a partial specialization? if not, this will be an explicit specialization
* @return
*/
- public boolean isPartialSpecialization();
+ public boolean isPartialSpecialization() throws DOMException;
/**
* get the ICPPTemplateDefinition which this is a specialization of
* @return
*/
- public ICPPTemplateDefinition getPrimaryTemplateDefinition();
+ public ICPPTemplateDefinition getPrimaryTemplateDefinition() throws DOMException;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java
new file mode 100644
index 00000000000..47d9648cbb9
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateTemplateParameter.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 13, 2005
+ */
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IType;
+
+/**
+ * @author aniefer
+ */
+public interface ICPPTemplateTemplateParameter extends ICPPTemplateParameter, ICPPClassTemplate {
+
+ public ICPPTemplateParameter[] getTemplateParameters() throws DOMException;
+
+ /**
+ * The default type for this parameter. May be null
+ *
+ * @return
+ */
+ public IType getDefault() throws DOMException;
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
index 9a636dfec85..119516d1ba4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CBasicType.java
@@ -10,6 +10,7 @@
**********************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
@@ -97,4 +98,12 @@ public class CBasicType implements ICBasicType {
}
return t;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBasicType#getValue()
+ */
+ public IASTExpression getValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java
index 7a223a88f68..89a2b2e361e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplatedTypeTemplateParameter.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -102,11 +102,11 @@ public class CPPASTTemplatedTypeTemplateParameter extends CPPASTNode implements
}
}
- if( name != null ) if( !name.accept( action ) ) return false;
ICPPASTTemplateParameter [] ps = getTemplateParameters();
for ( int i = 0; i < ps.length; i++ ) {
if( !ps[i].accept( action ) ) return false;
}
+ if( name != null ) if( !name.accept( action ) ) return false;
if( defaultValue != null ) if( !defaultValue.accept( action ) ) return false;
return true;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
index 714d4c13a72..01bf70291e8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBasicType.java
@@ -13,7 +13,9 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
/**
@@ -28,19 +30,32 @@ public class CPPBasicType implements ICPPBasicType {
protected int qualifierBits = 0;
protected int type;
+ protected IASTExpression value = null;
public CPPBasicType( int t, int bits ){
type = t;
qualifierBits = bits;
}
+ public CPPBasicType( int t, int bits, IASTExpression val ){
+ type = t;
+ qualifierBits = bits;
+ value = val;
+ }
+
public boolean isSameType( IType object ) {
- if( object instanceof CPPTypedef )
+ if( object == this )
+ return true;
+
+ if( object instanceof ITypedef )
return object.isSameType( this );
if( !(object instanceof CPPBasicType) )
return false;
+ if( type == -1 )
+ return false;
+
CPPBasicType t = (CPPBasicType) object;
return ( type == t.type && qualifierBits == t.qualifierBits );
}
@@ -88,4 +103,15 @@ public class CPPBasicType implements ICPPBasicType {
}
return t;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBasicType#getValue()
+ */
+ public IASTExpression getValue() {
+ return value;
+ }
+
+ public void setValue( IASTExpression val ){
+ value = val;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
index 76897e42876..c22231e9ff3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java
@@ -34,16 +34,15 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
* @author aniefer
*/
public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPPInternalBinding {
- private IASTName id;
private CPPClassInstanceScope instanceScope;
/**
* @param decl
+ * @param args
* @param arguments
*/
- public CPPClassInstance( IASTName id, ICPPScope scope, IBinding decl, ObjectMap argMap ) {
- super( scope, decl, argMap );
- this.id = id;
+ public CPPClassInstance( ICPPScope scope, IBinding decl, ObjectMap argMap, IType[] args ) {
+ super( scope, decl, argMap, args );
}
/* (non-Javadoc)
@@ -163,7 +162,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
*/
public Object clone(){
// TODO Auto-generated method stub
- return null;
+ return this;
}
/* (non-Javadoc)
@@ -178,7 +177,7 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
*/
public IASTNode getDefinition() {
- return id;
+ return null;
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java
index 155dbfe8ecd..71f1380679e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java
@@ -83,7 +83,7 @@ public class CPPClassInstanceScope implements ICPPClassScope {
} else {
binding = forceResolve ? n.resolveBinding() : n.getBinding();
if( binding != null ){
- binding = CPPTemplates.createInstance( n, this, binding, instance.getArgumentMap() );
+ binding = CPPTemplates.createInstance( this, binding, instance.getArgumentMap(), instance.getArguments() );
if( instanceMap == ObjectMap.EMPTY_MAP )
instanceMap = new ObjectMap(2);
instanceMap.put( n, binding );
@@ -93,7 +93,7 @@ public class CPPClassInstanceScope implements ICPPClassScope {
if( instanceMap.containsKey( obj ) ){
binding = (IBinding) instanceMap.get( obj );
} else {
- binding = CPPTemplates.createInstance( null, this, (IBinding) obj, instance.getArgumentMap() );
+ binding = CPPTemplates.createInstance( this, (IBinding) obj, instance.getArgumentMap(), instance.getArguments() );
if( instanceMap == ObjectMap.EMPTY_MAP )
instanceMap = new ObjectMap(2);
instanceMap.put( obj, binding );
@@ -175,8 +175,16 @@ public class CPPClassInstanceScope implements ICPPClassScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
*/
- public IScope getParent() {
- // TODO Auto-generated method stub
+ public IScope getParent() throws DOMException {
+ ICPPClassType cls = getOriginalClass();
+ ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
+ if( scope != null )
+ return scope.getParent();
+ if( cls instanceof ICPPInternalBinding ){
+ IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations();
+ if( nds != null && nds.length > 0 )
+ return CPPVisitor.getContainingScope( nds[0] );
+ }
return null;
}
@@ -192,8 +200,17 @@ public class CPPClassInstanceScope implements ICPPClassScope {
* @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode()
*/
public IASTNode getPhysicalNode() throws DOMException {
- ICPPClassScope scope = (ICPPClassScope) getOriginalClass().getCompositeScope();
- return scope.getPhysicalNode();
+ ICPPClassType cls = getOriginalClass();
+ ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
+ if( scope != null )
+ return scope.getPhysicalNode();
+
+ if( cls instanceof ICPPInternalBinding ){
+ IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations();
+ if( nds != null && nds.length > 0 )
+ return nds[0];
+ }
+ return null;
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
index aaa6f0f5861..03b1d0cf61c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java
@@ -23,25 +23,22 @@ import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
-import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
* @author aniefer
*/
public class CPPClassTemplate extends CPPTemplateDefinition implements
ICPPClassTemplate, ICPPClassType, ICPPInternalClassType {
-
+
/**
* @param decl
*/
@@ -49,24 +46,14 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
super(name);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplate#instantiate(org.eclipse.cdt.core.dom.ast.IASTNode[])
- */
- public IBinding instantiate(ICPPASTTemplateId templateId ) {//IASTNode[] arguments) {
- ICPPTemplateParameter [] params = getTemplateParameters();
- IASTNode [] arguments = templateId.getTemplateArguments();
-
- ObjectMap map = new ObjectMap(params.length);
- if( arguments.length == params.length ){
- for( int i = 0; i < arguments.length; i++ ){
- IType t = CPPVisitor.createType( arguments[i] );
- map.put( params[i], t );
- }
+ public ICPPTemplateInstance deferredInstance( IType [] arguments ){
+ ICPPTemplateInstance instance = getInstance( arguments );
+ if( instance == null ){
+ instance = new CPPDeferredClassInstance( this, arguments );
+ addInstance( arguments, instance );
}
-
- return CPPTemplates.createInstance( templateId, (ICPPScope) getScope(), this, map );
+ return instance;
}
-
private void checkForDefinition(){
// CPPClassType.FindDefinitionAction action = new FindDefinitionAction();
// IASTNode node = CPPVisitor.getContainingBlockItem( getPhysicalNode() ).getParent();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
index d18d7573a65..73b1a1a5c69 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
@@ -13,10 +13,16 @@
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
* @author aniefer
@@ -24,19 +30,22 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
public class CPPClassTemplateSpecialization extends CPPClassTemplate implements
ICPPTemplateSpecialization {
- private IASTNode [] arguments;
+ private IType [] arguments;
/**
* @param name
*/
public CPPClassTemplateSpecialization(ICPPASTTemplateId name) {
super(name);
- this.arguments = name.getTemplateArguments();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization#getArguments()
*/
- public IASTNode[] getArguments() {
+ public IType[] getArguments() {
+ if( arguments == null ){
+ ICPPASTTemplateId id = (ICPPASTTemplateId) getTemplateName();
+ arguments = CPPTemplates.createTypeArray( id.getTemplateArguments() );
+ }
return arguments;
}
@@ -55,4 +64,45 @@ public class CPPClassTemplateSpecialization extends CPPClassTemplate implements
return (ICPPTemplateDefinition) id.getTemplateName().resolveBinding();
}
+ public IBinding instantiate( IType [] args ){
+ ICPPTemplateInstance instance = getInstance( args );
+ if( instance != null ){
+ return instance;
+ }
+
+ IType [] specArgs = getArguments();
+ if( specArgs.length != arguments.length ){
+ return null;
+ }
+
+ ObjectMap argMap = new ObjectMap( specArgs.length );
+ int numSpecArgs = specArgs.length;
+ for( int i = 0; i < numSpecArgs; i++ ){
+ IType spec = specArgs[i];
+ IType arg = args[i];
+
+ //If the argument is a template parameter, we can't instantiate yet, defer for later
+ if( arg instanceof ICPPTemplateParameter ){
+ return deferredInstance( args );
+ }
+ try {
+ if( !CPPTemplates.deduceTemplateArgument( argMap, spec, arg ) )
+ return null;
+ } catch (DOMException e) {
+ return null;
+ }
+ }
+
+ ICPPTemplateParameter [] params = getTemplateParameters();
+ int numParams = params.length;
+ for( int i = 0; i < numParams; i++ ){
+ if( params[i] instanceof IType && !argMap.containsKey( params[i] ) )
+ return null;
+ }
+
+ instance = (ICPPTemplateInstance) CPPTemplates.createInstance( (ICPPScope) getScope(), this, argMap, args );
+ addInstance( args, instance );
+
+ return instance;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
index 7030d2e6c5c..9615798cbf8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java
@@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
@@ -634,10 +635,14 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
ObjectSet resultSet = new ObjectSet(2);
IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers();
for( int i = 0; i < members.length; i++ ){
- if( members[i] instanceof IASTSimpleDeclaration ){
- ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)members[i]).getDeclSpecifier();
+ IASTDeclaration decl = members[i];
+ while( decl instanceof ICPPASTTemplateDeclaration )
+ decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
+
+ if( decl instanceof IASTSimpleDeclaration ){
+ ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
if( declSpec.isFriend() ){
- IASTDeclarator [] dtors = ((IASTSimpleDeclaration)members[i]).getDeclarators();
+ IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
if( declSpec instanceof ICPPASTElaboratedTypeSpecifier && dtors.length == 0 ){
resultSet.put( ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding() );
} else {
@@ -647,10 +652,10 @@ public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
}
}
}
- } else if( members[i] instanceof IASTFunctionDefinition ){
- ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)members[i]).getDeclSpecifier();
+ } else if( decl instanceof IASTFunctionDefinition ){
+ ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
if( declSpec.isFriend() ){
- IASTDeclarator dtor = ((IASTFunctionDefinition)members[i]).getDeclarator();
+ IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
resultSet.put( dtor.getName().resolveBinding() );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
new file mode 100644
index 00000000000..e24faa84b98
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 14, 2005
+ */
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.parser.util.ObjectMap;
+
+/**
+ * @author aniefer
+ */
+public class CPPDeferredClassInstance /*extends CPPInstance*/ implements
+ ICPPTemplateInstance, ICPPClassType, ICPPInternalBinding {
+
+ public IType [] arguments = null;
+ public ICPPClassTemplate classTemplate = null;
+
+ public CPPDeferredClassInstance(ICPPClassTemplate orig, IType [] arguments ) {
+ this.arguments = arguments;
+ this.classTemplate = orig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getArguments()
+ */
+ public IType[] getArguments() {
+ return arguments;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
+ */
+ public ICPPBase[] getBases() throws DOMException {
+ return ICPPBase.EMPTY_BASE_ARRAY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
+ */
+ public IField[] getFields() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
+ */
+ public IField findField(String name) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
+ */
+ public ICPPField[] getDeclaredFields() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
+ */
+ public ICPPMethod[] getMethods() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
+ */
+ public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
+ */
+ public ICPPMethod[] getDeclaredMethods() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
+ */
+ public ICPPConstructor[] getConstructors() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
+ */
+ public IBinding[] getFriends() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
+ */
+ public IASTNode[] getDeclarations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
+ */
+ public IASTNode getDefinition() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
+ */
+ public ICPPDelegate createDelegate(IASTName name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
+ */
+ public int getKey() throws DOMException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
+ */
+ public IScope getCompositeScope() throws DOMException {
+ return ((ICPPClassType)classTemplate).getCompositeScope();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
+ */
+ public String[] getQualifiedName() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
+ */
+ public char[][] getQualifiedNameCharArray() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
+ */
+ public boolean isGloballyQualified() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#clone()
+ */
+ public Object clone(){
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
+ */
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
+ */
+ public char[] getNameCharArray() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
+ */
+ public IScope getScope() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDefinition(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDeclaration(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getOriginalBinding()
+ */
+ public IBinding getOriginalBinding() {
+ return classTemplate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getArgumentMap()
+ */
+ public ObjectMap getArgumentMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getTemplate()
+ */
+ public ICPPTemplateDefinition getTemplate() {
+ return classTemplate;
+ }
+
+ /**
+ * @param argMap
+ * @return
+ */
+ public IType instantiate(ObjectMap argMap) {
+
+ IType [] newArgs = new IType[ arguments.length ];
+ int size = arguments.length;
+ for( int i = 0; i < size; i++ ){
+ newArgs[i] = CPPTemplates.instantiateType( arguments[i], argMap );
+ }
+
+ return (IType) ((CPPTemplateDefinition)classTemplate).instantiate( newArgs );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
+ */
+ public boolean isSameType(IType type) {
+ // TODO Auto-generated method stub
+ return type == this;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunctionInstance.java
new file mode 100644
index 00000000000..39148a3073b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunctionInstance.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 14, 2005
+ */
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.parser.util.ObjectMap;
+
+/**
+ * @author aniefer
+ */
+public class CPPDeferredFunctionInstance /*extends CPPInstance*/ implements
+ ICPPFunction, ICPPTemplateInstance, ICPPInternalBinding {
+
+ private IType[] arguments;
+ private ICPPFunctionTemplate functionTemplate;
+
+ /**
+ * @param scope
+ * @param orig
+ * @param argMap
+ */
+ public CPPDeferredFunctionInstance( ICPPFunctionTemplate template, IType[] arguments ) {
+ this.functionTemplate = template;
+ this.arguments = arguments;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getArguments()
+ */
+ public IType[] getArguments() {
+ return arguments;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#getParameters()
+ */
+ public IParameter[] getParameters() throws DOMException {
+ return ((ICPPFunction)functionTemplate).getParameters();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#getFunctionScope()
+ */
+ public IScope getFunctionScope() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#getType()
+ */
+ public IFunctionType getType() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#isStatic()
+ */
+ public boolean isStatic() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
+ */
+ public String[] getQualifiedName() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
+ */
+ public char[][] getQualifiedNameCharArray() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
+ */
+ public boolean isGloballyQualified() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
+ */
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
+ */
+ public char[] getNameCharArray() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
+ */
+ public IScope getScope() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getOriginalBinding()
+ */
+ public IBinding getOriginalBinding() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getArgumentMap()
+ */
+ public ObjectMap getArgumentMap() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getTemplate()
+ */
+ public ICPPTemplateDefinition getTemplate() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction#isMutable()
+ */
+ public boolean isMutable() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction#isInline()
+ */
+ public boolean isInline() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#isExtern()
+ */
+ public boolean isExtern() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#isAuto()
+ */
+ public boolean isAuto() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#isRegister()
+ */
+ public boolean isRegister() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IFunction#takesVarArgs()
+ */
+ public boolean takesVarArgs() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
+ */
+ public IASTNode[] getDeclarations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
+ */
+ public IASTNode getDefinition() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
+ */
+ public ICPPDelegate createDelegate(IASTName name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDefinition(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDeclaration(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldInstance.java
index 02fb9e06759..5c5b482ef72 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFieldInstance.java
@@ -30,9 +30,10 @@ public class CPPFieldInstance extends CPPInstance implements ICPPField {
/**
* @param orig
* @param args
+ * @param args
*/
- public CPPFieldInstance(ICPPScope scope, IBinding orig, ObjectMap argMap ) {
- super(scope, orig, argMap);
+ public CPPFieldInstance(ICPPScope scope, IBinding orig, ObjectMap argMap, IType[] args ) {
+ super(scope, orig, argMap, args);
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java
index ba19fceda15..f89aa9b7c55 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java
@@ -20,6 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
@@ -35,9 +36,10 @@ public class CPPFunctionInstance extends CPPInstance implements ICPPFunction, IC
* @param scope
* @param orig
* @param argMap
+ * @param args
*/
- public CPPFunctionInstance(ICPPScope scope, IBinding orig, ObjectMap argMap) {
- super(scope, orig, argMap);
+ public CPPFunctionInstance(ICPPScope scope, IBinding orig, ObjectMap argMap, IType[] args) {
+ super(scope, orig, argMap, args);
// TODO Auto-generated constructor stub
}
@@ -72,7 +74,7 @@ public class CPPFunctionInstance extends CPPInstance implements ICPPFunction, IC
IParameter [] params = ((ICPPFunction)getOriginalBinding()).getParameters();
parameters = new IParameter[ params.length ];
for (int i = 0; i < params.length; i++) {
- parameters[i] = new CPPParameterInstance( null, params[i], getArgumentMap() );
+ parameters[i] = new CPPParameterInstance( null, params[i], getArgumentMap(), getArguments() );
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
index c66672da902..275ed7174b4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
@@ -31,18 +31,68 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
-import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
/**
* @author aniefer
*/
public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFunctionTemplate, ICPPFunction {
- IFunctionType type = null;
+ public static final class CPPFunctionTemplateProblem extends ProblemBinding implements ICPPFunctionTemplate, ICPPFunction {
+ public CPPFunctionTemplateProblem(IASTNode node, int id, char[] arg) {
+ super(node, id, arg);
+ }
+ public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
+ throw new DOMException( this );
+ }
+ public ICPPTemplateSpecialization[] getTemplateSpecializations() throws DOMException {
+ throw new DOMException( this );
+ }
+ public String[] getQualifiedName() throws DOMException {
+ throw new DOMException( this );
+ }
+ public char[][] getQualifiedNameCharArray() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isGloballyQualified() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isMutable() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isInline() throws DOMException {
+ throw new DOMException( this );
+ }
+ public IParameter[] getParameters() throws DOMException {
+ throw new DOMException( this );
+ }
+ public IScope getFunctionScope() throws DOMException {
+ throw new DOMException( this );
+ }
+ public IFunctionType getType() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isStatic() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isExtern() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isAuto() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isRegister() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean takesVarArgs() throws DOMException {
+ throw new DOMException( this );
+ }
+ }
+ protected IFunctionType type = null;
/**
* @param decl
*/
@@ -85,24 +135,6 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
}
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplate#instantiate(org.eclipse.cdt.core.dom.ast.IASTNode[])
- */
- public IBinding instantiate(ICPPASTTemplateId templateId ) {//IASTNode[] arguments) {
- ICPPTemplateParameter [] params = getTemplateParameters();
- IASTNode [] arguments = templateId.getTemplateArguments();
-
- ObjectMap map = new ObjectMap(params.length);
- if( arguments.length == params.length ){
- for( int i = 0; i < arguments.length; i++ ){
- IType t = CPPVisitor.createType( arguments[i] );
- map.put( params[i], t );
- }
- }
-
- return CPPTemplates.createInstance( templateId, (ICPPScope) getScope(), this, map );
- }
-
/**
* @param templateParameter
* @return
@@ -233,6 +265,12 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition implements ICPPFu
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition#deferredInstance(org.eclipse.cdt.core.dom.ast.IType[])
+ */
+ public ICPPTemplateInstance deferredInstance(IType[] arguments) {
+ return new CPPDeferredFunctionInstance( this, arguments );
+ }
+ /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IFunction#isStatic()
*/
public boolean isStatic() {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java
new file mode 100644
index 00000000000..4ce07b742a7
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplateSpecialization.java
@@ -0,0 +1,58 @@
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+
+public class CPPFunctionTemplateSpecialization extends CPPFunction implements
+ ICPPTemplateSpecialization {
+
+ private IASTName name = null;
+ private IType [] argumentTypes = null;
+ private ICPPFunctionTemplate primaryTemplate = null;
+
+ public CPPFunctionTemplateSpecialization(ICPPASTFunctionDeclarator declarator, ICPPFunctionTemplate primaryTemplate ) {
+ super(declarator);
+ this.primaryTemplate = primaryTemplate;
+ IASTName n = declarator.getName();
+ if( n instanceof ICPPASTQualifiedName ){
+ IASTName [] ns = ((ICPPASTQualifiedName)n).getNames();
+ n = ns[ ns.length - 1 ];
+ }
+ this.name = n;
+ }
+
+ public IType [] getArguments() throws DOMException{
+ if( argumentTypes == null ){
+ IASTNode [] specArgs = ( name instanceof ICPPASTTemplateId ) ? ((ICPPASTTemplateId)name).getTemplateArguments()
+ : IASTNode.EMPTY_NODE_ARRAY;
+ argumentTypes = CPPTemplates.deduceTemplateFunctionArguments( this, specArgs );
+ }
+ return argumentTypes;
+ }
+
+ public boolean isPartialSpecialization() {
+ return false;
+ }
+
+ public ICPPTemplateDefinition getPrimaryTemplateDefinition() {
+ return primaryTemplate;
+ }
+
+ public ICPPTemplateParameter[] getTemplateParameters() {
+ return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
+ }
+
+ public ICPPTemplateSpecialization[] getTemplateSpecializations() {
+ return ICPPTemplateSpecialization.EMPTY_TEMPLATE_SPECIALIZATION_ARRAY;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java
index 8f49206e267..0d7a06fbfb4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPInstance.java
@@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
@@ -26,13 +27,15 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
*/
public class CPPInstance implements ICPPTemplateInstance {
private IBinding binding;
+ private IType [] arguments;
private ObjectMap argMap;
private ICPPScope scope;
- public CPPInstance( ICPPScope scope, IBinding orig, ObjectMap argMap ){
+ public CPPInstance( ICPPScope scope, IBinding orig, ObjectMap argMap, IType [] arguments ){
this.binding = orig;
this.argMap = argMap;
this.scope = scope;
+ this.arguments = arguments;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPInstance#getOriginalBinding()
@@ -91,4 +94,10 @@ public class CPPInstance implements ICPPTemplateInstance {
// TODO Auto-generated method stub
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance#getArguments()
+ */
+ public IType[] getArguments() {
+ return arguments;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
index 171cc070ef8..4d16cb71d3d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethodInstance.java
@@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.parser.util.ObjectMap;
@@ -29,9 +30,10 @@ public class CPPMethodInstance extends CPPFunctionInstance implements
* @param scope
* @param orig
* @param argMap
+ * @param args
*/
- public CPPMethodInstance(ICPPScope scope, IBinding orig, ObjectMap argMap) {
- super(scope, orig, argMap);
+ public CPPMethodInstance(ICPPScope scope, IBinding orig, ObjectMap argMap, IType[] args) {
+ super(scope, orig, argMap, args);
// TODO Auto-generated constructor stub
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
index afcd4f1cee0..f01e7976727 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
@@ -18,6 +18,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
@@ -25,14 +26,14 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
/**
* @author aniefer
*/
-public class CPPParameter implements IParameter, ICPPInternalBinding, ICPPVariable {
- public static class CPPParameterDelegate extends CPPDelegate implements IParameter, ICPPVariable {
+public class CPPParameter implements ICPPParameter, ICPPInternalBinding {
+ public static class CPPParameterDelegate extends CPPDelegate implements ICPPParameter {
public CPPParameterDelegate( IASTName name, IParameter binding ) {
super( name, binding );
}
@@ -54,6 +55,9 @@ public class CPPParameter implements IParameter, ICPPInternalBinding, ICPPVariab
public boolean isMutable() {
return false;
}
+ public IASTInitializer getDefaultValue() {
+ return ((ICPPParameter)getBinding()).getDefaultValue();
+ }
}
private IType type = null;
@@ -244,4 +248,18 @@ public class CPPParameter implements IParameter, ICPPInternalBinding, ICPPVariab
}
return false;
}
+
+ public IASTInitializer getDefaultValue() {
+ if( declarations == null )
+ return null;
+ for (int i = 0; i < declarations.length && declarations[i] != null; i++) {
+ IASTNode parent = declarations[i].getParent();
+ while( parent.getPropertyInParent() == IASTDeclarator.NESTED_DECLARATOR )
+ parent = parent.getParent();
+ IASTInitializer init = ((IASTDeclarator)parent).getInitializer();
+ if( init != null )
+ return init;
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterInstance.java
index 0e014036916..dde664b4475 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterInstance.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameterInstance.java
@@ -14,21 +14,21 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.parser.util.ObjectMap;
/**
* @author aniefer
*/
-public class CPPParameterInstance extends CPPInstance implements IParameter,
- ICPPVariable, ICPPInternalBinding {
+public class CPPParameterInstance extends CPPInstance implements ICPPParameter, ICPPInternalBinding {
private IType type = null;
@@ -37,8 +37,8 @@ public class CPPParameterInstance extends CPPInstance implements IParameter,
* @param orig
* @param argMap
*/
- public CPPParameterInstance(ICPPScope scope, IBinding orig, ObjectMap argMap) {
- super(scope, orig, argMap);
+ public CPPParameterInstance(ICPPScope scope, IBinding orig, ObjectMap argMap, IType [] args ) {
+ super(scope, orig, argMap, args);
}
/* (non-Javadoc)
@@ -131,4 +131,8 @@ public class CPPParameterInstance extends CPPInstance implements IParameter,
return false;
}
+ public IASTInitializer getDefaultValue() {
+ return ((ICPPParameter)getOriginalBinding()).getDefaultValue();
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java
index ad5c97511e9..a4168614b4e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPPointerType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -49,6 +49,16 @@ public class CPPPointerType implements IPointerType, ITypeContainer {
this.type = type;
}
+ public IType stripQualifiers(){
+ CPPPointerType result = this;
+ if( isConst || isVolatile ){
+ result = (CPPPointerType) clone();
+ result.isConst = false;
+ result.isVolatile = false;
+ }
+ return result;
+ }
+
public boolean isSameType( IType o ){
if( o == this )
return true;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java
index 00a8e449393..34f967a5660 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPQualifierType.java
@@ -25,7 +25,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
public class CPPQualifierType implements IQualifierType, ITypeContainer {
private boolean isConst = false;
private boolean isVolatile = false;
- private boolean fromStringLiteral = false;
private IType type = null;
public CPPQualifierType( IType type, boolean isConst, boolean isVolatile ){
@@ -80,15 +79,4 @@ public class CPPQualifierType implements IQualifierType, ITypeContainer {
}
return t;
}
-
- /**
- * @return
- */
- public boolean fromStringLiteral() {
- return fromStringLiteral;
- }
-
- public void setFromStringLiteral( boolean fromString ){
- fromStringLiteral = fromString;
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index 1abf0786a3d..f36abcd4485 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -35,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerExpression;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
@@ -75,11 +76,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
@@ -88,11 +91,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
@@ -136,7 +141,7 @@ public class CPPSemantics {
public boolean considerConstructors = false;
public Object foundItems = null;
public Object [] functionParameters;
- public IASTNode [] templateParameters;
+ public IASTNode [] templateArguments;
public ProblemBinding problem;
@@ -155,7 +160,8 @@ public class CPPSemantics {
if( astName.getPropertyInParent() == STRING_LOOKUP_PROPERTY ) return true;
if( ( astName != null && astName.getParent() instanceof IASTIdExpression ) ||
item instanceof IASTNamespaceDefinition ||
- (item instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration)item).getDeclSpecifier() instanceof IASTCompositeTypeSpecifier ) )
+ (item instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration)item).getDeclSpecifier() instanceof IASTCompositeTypeSpecifier ) ||
+ item instanceof ICPPASTTemplateDeclaration )
{
return true;
}
@@ -463,6 +469,18 @@ public class CPPSemantics {
binding = e.getProblem();
}
}
+ if( binding instanceof ICPPClassTemplate ){
+ ASTNodeProperty prop = data.astName.getPropertyInParent();
+ if( prop != ICPPASTQualifiedName.SEGMENT_NAME && prop != ICPPASTTemplateId.TEMPLATE_NAME ){
+ try {
+ IScope scope = ((ICPPClassType)binding).getCompositeScope();
+ if( CPPVisitor.getContainingScope( data.astName ) == scope ){
+ binding = CPPTemplates.instantiateWithinClassTemplate( (ICPPClassTemplate) binding );
+ }
+ } catch( DOMException e ) {
+ }
+ }
+ }
if( binding instanceof ICPPClassType && data.considerConstructors ){
ICPPClassType cls = (ICPPClassType) binding;
try {
@@ -479,7 +497,12 @@ public class CPPSemantics {
}
if( binding != null ) {
if( data.astName.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !( binding instanceof IType || binding instanceof ICPPConstructor) ){
- binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.name );
+ IASTNode parent = data.astName.getParent().getParent();
+ if( parent instanceof IASTTypeId && parent.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT ){
+ //don't do a problem here
+ } else {
+ binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.name );
+ }
}
}
@@ -497,13 +520,14 @@ public class CPPSemantics {
CPPSemantics.LookupData data = new CPPSemantics.LookupData( name );
IASTNode parent = name.getParent();
- if( parent instanceof ICPPASTTemplateId ){
- data.templateParameters = ((ICPPASTTemplateId)parent).getTemplateArguments();
- parent = parent.getParent();
+ if( name instanceof ICPPASTTemplateId ){
+ data.templateArguments = ((ICPPASTTemplateId)name).getTemplateArguments();
}
- if( parent instanceof ICPPASTQualifiedName ){
+
+ if( parent instanceof ICPPASTTemplateId )
+ parent = parent.getParent();
+ if( parent instanceof ICPPASTQualifiedName )
parent = parent.getParent();
- }
if( parent instanceof IASTDeclarator && parent.getPropertyInParent() == IASTSimpleDeclaration.DECLARATOR ){
IASTSimpleDeclaration simple = (IASTSimpleDeclaration) parent.getParent();
@@ -583,7 +607,9 @@ public class CPPSemantics {
if( t instanceof ICPPClassType ){
if( !classes.containsKey( t ) ){
classes.put( t );
- namespaces.put( getContainingNamespaceScope( (IBinding) t ) );
+ IScope scope = getContainingNamespaceScope( (IBinding) t );
+ if( scope != null )
+ namespaces.put( scope );
ICPPClassType cls = (ICPPClassType) t;
ICPPBase[] bases = cls.getBases();
@@ -694,7 +720,7 @@ public class CPPSemantics {
return resultMap;
}
- static private void lookup( CPPSemantics.LookupData data, Object start ) throws DOMException{
+ static protected void lookup( CPPSemantics.LookupData data, Object start ) throws DOMException{
IASTNode node = data.astName;
ICPPScope scope = null;
@@ -780,7 +806,11 @@ public class CPPSemantics {
}
private static Object lookupInParents( CPPSemantics.LookupData data, ICPPClassScope lookIn ) throws DOMException{
- ICPPASTCompositeTypeSpecifier compositeTypeSpec = (ICPPASTCompositeTypeSpecifier) lookIn.getPhysicalNode();
+ IASTNode node = lookIn.getPhysicalNode();
+ if( node == null || !(node instanceof ICPPASTCompositeTypeSpecifier) )
+ return null;
+
+ ICPPASTCompositeTypeSpecifier compositeTypeSpec = (ICPPASTCompositeTypeSpecifier) node;
ICPPASTBaseSpecifier [] bases = compositeTypeSpec.getBaseSpecifiers();
Object inherited = null;
@@ -854,13 +884,13 @@ public class CPPSemantics {
if( result instanceof Object [] ){
Object [] r = (Object[]) result;
for( int j = 0; j < r.length && r[j] != null; j++ ) {
- if( checkForAmbiguity( r[j], inherited ) ){
+ if( checkForAmbiguity( data, r[j], inherited ) ){
data.problem = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
return null;
}
}
} else {
- if( checkForAmbiguity( result, inherited ) ){
+ if( checkForAmbiguity( data, result, inherited ) ){
data.problem = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
return null;
}
@@ -908,14 +938,13 @@ public class CPPSemantics {
}
}
}
- private static boolean checkForAmbiguity( Object n, Object names ) throws DOMException{
+ private static boolean checkForAmbiguity( LookupData data, Object n, Object names ) throws DOMException{
if( names instanceof Object[] ) {
names = ArrayUtil.trim( Object.class, (Object[]) names );
if( ((Object[])names).length == 0 )
return false;
}
- //it is not ambiguous if they are the same thing and it is static or an enumerator
IBinding binding = ( n instanceof IBinding) ? (IBinding)n : ((IASTName)n).resolveBinding();
Object [] objs = ( names instanceof Object[] ) ? (Object[])names : null;
int idx = ( objs != null && objs.length > 0 ) ? 0 : -1;
@@ -925,13 +954,29 @@ public class CPPSemantics {
if( binding != b )
return true;
- if( !(binding instanceof IEnumerator) &&
- !( (binding instanceof IFunction && ((IFunction)binding).isStatic()) ||
- (binding instanceof IVariable && ((IVariable)binding).isStatic()) ) )
+
+ boolean ok = false;
+ //3.4.5-4 if the id-expression in a class member access is a qualified id... the result
+ //is not required to be a unique base class...
+ if( binding instanceof ICPPClassType ){
+ IASTNode parent = data.astName.getParent();
+ if( parent instanceof ICPPASTQualifiedName &&
+ parent.getPropertyInParent() == IASTFieldReference.FIELD_NAME )
+ {
+ ok = true;
+ }
+ }
+ //it is not ambiguous if they are the same thing and it is static or an enumerator
+ if( binding instanceof IEnumerator ||
+ (binding instanceof IFunction && ((IFunction)binding).isStatic()) ||
+ (binding instanceof IVariable && ((IVariable)binding).isStatic()) )
{
- return true;
+ ok = true;
}
-
+ if( !ok )
+ return true;
+
+ next:
if( idx > -1 && idx < objs.length )
o = objs[idx++];
else
@@ -1028,6 +1073,12 @@ public class CPPSemantics {
} else if ( parent instanceof ICPPASTCompositeTypeSpecifier ){
ICPPASTCompositeTypeSpecifier comp = (ICPPASTCompositeTypeSpecifier) parent;
nodes = comp.getMembers();
+
+ //9-2 a class name is also inserted into the scope of the class itself
+ IASTName n = comp.getName();
+ if( nameMatches( data, n ) ) {
+ found = (IASTName[]) ArrayUtil.append( IASTName.class, found, n );
+ }
} else if ( parent instanceof ICPPASTNamespaceDefinition ){
//need binding because namespaces can be split
CPPNamespace namespace = (CPPNamespace) ((ICPPASTNamespaceDefinition)parent).getName().resolveBinding();
@@ -1123,6 +1174,8 @@ public class CPPSemantics {
}
}
}
+
+
scope.setFullyCached( true );
return found;
@@ -1453,7 +1506,11 @@ public class CPPSemantics {
(type instanceof ICPPDelegate && ((ICPPDelegate)type).getBinding() == temp) )
{
//ok, delegates are synonyms
- } else if( type != temp ) {
+ } else if( type instanceof ICPPClassTemplate && temp instanceof ICPPTemplateSpecialization &&
+ ((ICPPTemplateSpecialization)temp).getPrimaryTemplateDefinition() == type )
+ {
+ //ok, stay with the template, the specialization, if applicable, will come out during instantiation
+ } else if( type != temp ) {
return new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
}
} else if( temp instanceof IFunction ){
@@ -1497,7 +1554,7 @@ public class CPPSemantics {
int numTemplateFns = templateFns.size();
if( numTemplateFns > 0 ){
- if( data.functionParameters != null && ( !data.forDefinition() || data.templateParameters != null ) ){
+ if( data.functionParameters != null && !data.forDefinition() ){
IFunction [] fs = CPPTemplates.selectTemplateFunctions( templateFns, data.functionParameters, data.astName );
if( fs != null && fs.length > 0){
if( fns == ObjectSet.EMPTY_SET )
@@ -1584,31 +1641,36 @@ public class CPPSemantics {
//if there are m arguments in the list, all candidate functions having m parameters
//are viable
if( num == numParameters ){
- if( data.forDefinition() && !functionHasParameters( fName, (IASTParameterDeclaration[]) data.functionParameters ) ){
+ if( data.forDefinition() && !isMatchingFunctionDeclaration( fName, data ) ){
functions[i] = null;
}
continue;
- } else if( function == null ){
- functions[i] = null;
- continue;
}
//check for void
else if( numParameters == 0 && num == 1 ){
- IASTParameterDeclaration param = function.getParameters()[0];
- IASTDeclSpecifier declSpec = param.getDeclSpecifier();
- if( declSpec instanceof IASTSimpleDeclSpecifier ){
- if( ((IASTSimpleDeclSpecifier)declSpec).getType() == IASTSimpleDeclSpecifier.t_void &&
- param.getDeclarator().getPointerOperators().length == 0 )
- {
- continue;
+ if( function != null ){
+ IASTParameterDeclaration param = function.getParameters()[0];
+ IASTDeclSpecifier declSpec = param.getDeclSpecifier();
+ if( declSpec instanceof IASTSimpleDeclSpecifier ){
+ if( ((IASTSimpleDeclSpecifier)declSpec).getType() == IASTSimpleDeclSpecifier.t_void &&
+ param.getDeclarator().getPointerOperators().length == 0 )
+ {
+ continue;
+ }
}
+ } else {
+ IParameter p = fName.getParameters()[0];
+ IType t = p.getType();
+ if( t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void )
+ continue;
+
}
}
//A candidate function having fewer than m parameters is viable only if it has an
//ellipsis in its parameter list.
if( num < numParameters ){
- if( function.takesVarArgs() ) {
+ if( (function != null && function.takesVarArgs()) || fName.takesVarArgs() ) {
continue;
}
//not enough parameters, remove it
@@ -1617,18 +1679,43 @@ public class CPPSemantics {
//a candidate function having more than m parameters is viable only if the (m+1)-st
//parameter has a default argument
else {
- IASTParameterDeclaration [] params = function.getParameters();
- for( int j = num - 1; j >= numParameters; j-- ){
- if( params[j].getDeclarator().getInitializer() == null ){
- functions[i] = null;
- size--;
- break;
+ if( function != null ) {
+ IASTParameterDeclaration [] params = function.getParameters();
+ for( int j = num - 1; j >= numParameters; j-- ){
+ if( params[j].getDeclarator().getInitializer() == null ){
+ functions[i] = null;
+ size--;
+ break;
+ }
+ }
+ } else {
+ IParameter [] params = fName.getParameters();
+ for( int j = num - 1; j >= numParameters; j-- ){
+ if( ((ICPPParameter)params[j]).getDefaultValue() == null ){
+ functions[i] = null;
+ size--;
+ break;
+ }
}
}
}
}
}
+ static private boolean isMatchingFunctionDeclaration( IFunction candidate, LookupData data ){
+ IASTName name = data.astName;
+ ICPPASTTemplateDeclaration decl = CPPTemplates.getTemplateDeclaration( name );
+ if( candidate instanceof ICPPTemplateDefinition && decl instanceof ICPPASTTemplateSpecialization ){
+ ICPPFunctionTemplate fn = CPPTemplates.resolveTemplateFunctions( new Object [] { candidate }, data.astName );
+ return ( fn != null && !(fn instanceof IProblemBinding ) );
+ }
+ try {
+ return functionHasParameters( candidate, (IASTParameterDeclaration[]) data.functionParameters );
+ } catch (DOMException e) {
+ }
+ return false;
+ }
+
static private IType getSourceParameterType( Object [] params, int idx ){
if( params instanceof IType[] ){
IType [] types = (IType[]) params;
@@ -1815,6 +1902,34 @@ public class CPPSemantics {
ambiguous |= ( hasWorse && hasBetter ) || ( !hasWorse && !hasBetter );
if( !hasWorse ){
+ //if they are both template functions, we can order them that way
+ boolean bestIsTemplate = (bestFn instanceof ICPPTemplateInstance &&
+ ((ICPPTemplateInstance)bestFn).getOriginalBinding() instanceof ICPPFunctionTemplate);
+ boolean currIsTemplate = (currFn instanceof ICPPTemplateInstance &&
+ ((ICPPTemplateInstance)currFn).getOriginalBinding() instanceof ICPPFunctionTemplate);
+ if( bestIsTemplate && currIsTemplate )
+ {
+ ICPPFunctionTemplate t1 = (ICPPFunctionTemplate) ((ICPPTemplateInstance)bestFn).getOriginalBinding();
+ ICPPFunctionTemplate t2 = (ICPPFunctionTemplate) ((ICPPTemplateInstance)currFn).getOriginalBinding();
+ int order = CPPTemplates.orderTemplateFunctions( t1, t2);
+ if ( order < 0 ){
+ hasBetter = true;
+ } else if( order > 0 ){
+ ambiguous = false;
+ }
+ }
+ //we prefer normal functions over template functions, unless we specified template arguments
+ else if( bestIsTemplate && !currIsTemplate ){
+ if( data.templateArguments == null )
+ hasBetter = true;
+ else
+ ambiguous = false;
+ } else if( !bestIsTemplate && currIsTemplate ){
+ if( data.templateArguments == null )
+ ambiguous = false;
+ else
+ hasBetter = true;
+ }
if( hasBetter ){
//the new best function.
ambiguous = false;
@@ -2049,7 +2164,7 @@ public class CPPSemantics {
return result;
}
- static private Cost checkStandardConversionSequence( IType source, IType target ) throws DOMException {
+ static protected Cost checkStandardConversionSequence( IType source, IType target ) throws DOMException {
Cost cost = lvalue_to_rvalue( source, target );
if( cost.source == null || cost.target == null ){
@@ -2288,8 +2403,18 @@ public class CPPSemantics {
else {
//4.2-2 a string literal can be converted to pointer to char
if( t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_char &&
- s instanceof CPPQualifierType && ((CPPQualifierType)s).fromStringLiteral() )
- canConvert = true;
+ s instanceof IQualifierType )
+ {
+ IType qt = ((IQualifierType)s).getType();
+ if( qt instanceof IBasicType ){
+ IASTExpression val = ((IBasicType)qt).getValue();
+ canConvert = (val != null &&
+ val instanceof IASTLiteralExpression &&
+ ((IASTLiteralExpression)val).getKind() == IASTLiteralExpression.lk_string_literal );
+ } else {
+ canConvert = false;
+ }
+ }
else
canConvert = false;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java
index 2e34b133702..df72b382dcf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java
@@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
+import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
@@ -22,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
@@ -29,59 +31,210 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
/**
* @author aniefer
*/
public abstract class CPPTemplateDefinition implements ICPPTemplateDefinition, ICPPInternalBinding {
+ public static final class CPPTemplateProblem extends ProblemBinding implements ICPPTemplateDefinition {
+ public CPPTemplateProblem(IASTNode node, int id, char[] arg) {
+ super(node, id, arg);
+ }
+ public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
+ throw new DOMException( this );
+ }
+ public ICPPTemplateSpecialization[] getTemplateSpecializations() throws DOMException {
+ throw new DOMException( this );
+ }
+ public String[] getQualifiedName() throws DOMException {
+ throw new DOMException( this );
+ }
+ public char[][] getQualifiedNameCharArray() throws DOMException {
+ throw new DOMException( this );
+ }
+ public boolean isGloballyQualified() throws DOMException {
+ throw new DOMException( this );
+ }
+ }
//private IASTName templateName;
protected IASTName [] declarations = null;
protected IASTName definition = null;
private ICPPTemplateParameter [] templateParameters = null;
private ICPPTemplateSpecialization [] specializations = null;
+ private ObjectMap instances = null;
public CPPTemplateDefinition( IASTName name ) {
- ASTNodeProperty prop = name.getPropertyInParent();
- if( prop == IASTCompositeTypeSpecifier.TYPE_NAME ){
- definition = name;
- } else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME ) {
- declarations = new IASTName [] { name };
- } else {
- IASTNode parent = name.getParent();
- while( !(parent instanceof IASTDeclaration) )
- parent = parent.getParent();
- if( parent instanceof IASTFunctionDefinition )
+ if( name != null ){
+ ASTNodeProperty prop = name.getPropertyInParent();
+ if( prop == IASTCompositeTypeSpecifier.TYPE_NAME ){
definition = name;
- else
+ } else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME ) {
declarations = new IASTName [] { name };
+ } else {
+ IASTNode parent = name.getParent();
+ while( !(parent instanceof IASTDeclaration) )
+ parent = parent.getParent();
+ if( parent instanceof IASTFunctionDefinition )
+ definition = name;
+ else
+ declarations = new IASTName [] { name };
+ }
}
}
- public abstract IBinding instantiate( ICPPASTTemplateId templateId );
+ public abstract ICPPTemplateInstance deferredInstance( IType [] arguments );
+
+ public IBinding instantiate(ICPPASTTemplateId templateId ) {//IASTNode[] arguments) {
+ IASTNode [] args = templateId.getTemplateArguments();
+ IType [] types = CPPTemplates.createTypeArray( args );
+ return instantiate( types );
+ }
- public ICPPTemplateSpecialization [] getSpecializations() {
+ public IBinding instantiate( IType [] arguments ){
+ ICPPTemplateDefinition template;
+ try {
+ template = CPPTemplates.matchTemplatePartialSpecialization( this, arguments );
+ } catch (DOMException e) {
+ return e.getProblem();
+ }
+
+ if( template != null && template instanceof ICPPTemplateSpecialization ){
+ return ((CPPTemplateDefinition)template).instantiate( arguments );
+ }
+
+ if( template == null ){
+ template = this;
+ }
+
+ ICPPTemplateParameter[] parameters = null;
+ try {
+ parameters = template.getTemplateParameters();
+ } catch (DOMException e1) {
+ return e1.getProblem();
+ }
+
+ int numParams = ( parameters != null ) ? parameters.length : 0;
+ int numArgs = arguments.length;
+
+ if( numParams == 0 ){
+ return null;
+ }
+
+ ObjectMap map = new ObjectMap( numParams );
+ ICPPTemplateParameter param = null;
+ IType arg = null;
+ IType[] actualArgs = new IType[ numParams ];
+
+ for( int i = 0; i < numParams; i++ ){
+
+ param = parameters[i];
+
+ if( i < numArgs ){
+ arg = arguments[i];
+ //If the argument is a template parameter, we can't instantiate yet, defer for later
+ if( arg instanceof ICPPTemplateParameter ){
+ return deferredInstance( arguments );
+ }
+ } else {
+ IType defaultType = null;
+ try {
+ if( param instanceof ICPPTemplateTypeParameter )
+ defaultType = ((ICPPTemplateTypeParameter)param).getDefault();
+ else if( param instanceof ICPPTemplateTemplateParameter )
+ defaultType = ((ICPPTemplateTemplateParameter)param).getDefault();
+ else if( param instanceof ICPPTemplateNonTypeParameter )
+ defaultType = CPPVisitor.getExpressionType( ((ICPPTemplateNonTypeParameter)param).getDefault() );
+ } catch (DOMException e) {
+ defaultType = e.getProblem();
+ }
+ if( defaultType != null ){
+ if( defaultType instanceof ICPPTemplateParameter ){
+ if( map.containsKey( defaultType ) ){
+ arg = (IType) map.get( defaultType );
+ }
+ }
+ } else {
+ //TODO problem
+ return null;
+ }
+ }
+
+ if( CPPTemplates.matchTemplateParameterAndArgument( param, arg ) ){
+ map.put( param, arg );
+ actualArgs[i] = arg;
+ } else {
+ //TODO problem
+ return null;
+ }
+ }
+
+ ICPPTemplateInstance instance = getInstance( actualArgs );
+ if( instance != null ){
+ return instance;
+ }
+
+ instance = (ICPPTemplateInstance) CPPTemplates.createInstance( (ICPPScope) getScope(), this, map, arguments );
+ addInstance( arguments, instance );
+
+ return instance;
+ }
+
+ public ICPPTemplateSpecialization [] getTemplateSpecializations() {
return (ICPPTemplateSpecialization[]) ArrayUtil.trim( ICPPTemplateSpecialization.class, specializations );
}
public void addSpecialization( ICPPTemplateSpecialization spec ){
specializations = (ICPPTemplateSpecialization[]) ArrayUtil.append( ICPPTemplateSpecialization.class, specializations, spec );
}
+ public ICPPTemplateInstance getInstance( IType [] arguments ) {
+ if( instances == null )
+ return null;
+
+ int found = -1;
+ for( int i = 0; i < instances.size(); i++ ){
+ IType [] args = (IType[]) instances.keyAt( i );
+ if( args.length == arguments.length ){
+ int j = 0;
+ for(; j < args.length; j++) {
+ if( !( args[j].equals( arguments[j] ) ) )
+ break;
+ }
+ if( j == args.length ){
+ found = i;
+ break;
+ }
+ }
+ }
+ if( found != -1 ){
+ return (ICPPTemplateInstance) instances.getAt(found);
+ }
+ return null;
+ }
+
+ public void addInstance( IType [] types, ICPPTemplateInstance instance ){
+ if( instances == null )
+ instances = new ObjectMap( 2 );
+ instances.put( types, instance );
+ }
public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) {
IASTName name = CPPTemplates.getTemplateParameterName( templateParameter );
IBinding binding = name.getBinding();
if( binding != null )
return binding;
-
- if( templateParameter.getParent() instanceof ICPPASTTemplatedTypeTemplateParameter ){
-
- }
-
+
ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) templateParameter.getParent();
ICPPASTTemplateParameter [] ps = templateDecl.getTemplateParameters();
@@ -92,7 +245,13 @@ public abstract class CPPTemplateDefinition implements ICPPTemplateDefinition, I
}
//create a new binding and set it for the corresponding parameter in all known decls
- binding = new CPPTemplateParameter( name );
+ if( templateParameter instanceof ICPPASTSimpleTypeTemplateParameter )
+ binding = new CPPTemplateTypeParameter( name );
+ else if( templateParameter instanceof ICPPASTParameterDeclaration )
+ binding = new CPPTemplateNonTypeParameter( name );
+ else
+ binding = new CPPTemplateTemplateParameter( name );
+
ICPPASTTemplateParameter temp = null;
ICPPASTTemplateDeclaration template = null;
int length = ( declarations != null ) ? declarations.length : 0;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
new file mode 100644
index 00000000000..2f8d72f0317
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 13, 2005
+ */
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
+
+/**
+ * @author aniefer
+ */
+public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements
+ ICPPTemplateNonTypeParameter {
+
+ private IType type = null;
+
+ /**
+ * @param name
+ */
+ public CPPTemplateNonTypeParameter(IASTName name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter#getDefault()
+ */
+ public IASTExpression getDefault() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
+ */
+ public IType getType() {
+ if( type == null ){
+ IASTName name = getPrimaryDeclaration();
+ IASTDeclarator dtor = (IASTDeclarator) name.getParent();
+ type = CPPVisitor.createType( dtor );
+ }
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
+ */
+ public boolean isStatic() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
+ */
+ public boolean isExtern() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
+ */
+ public boolean isAuto() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
+ */
+ public boolean isRegister() throws DOMException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
+ */
+ public ICPPDelegate createDelegate(IASTName name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDefinition(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDeclaration(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java
index dd4f2dd8eef..3f8b1067f68 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java
@@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
@@ -25,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
/**
* @author aniefer
*/
-public class CPPTemplateParameter implements ICPPTemplateParameter, IType, ICPPInternalBinding {
+public class CPPTemplateParameter implements ICPPTemplateParameter, ICPPInternalBinding {
private IASTName [] declarations;
public CPPTemplateParameter( IASTName name ){
@@ -141,15 +140,4 @@ public class CPPTemplateParameter implements ICPPTemplateParameter, IType, ICPPI
// TODO Auto-generated method stub
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
- */
- public boolean isSameType( IType type ) {
- if( type == this )
- return true;
- if( type instanceof ITypedef )
- return ((ITypedef)type).isSameType( this );
- return false;
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
new file mode 100644
index 00000000000..de0e4256944
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 13, 2005
+ */
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
+import org.eclipse.cdt.core.parser.util.ArrayUtil;
+
+/**
+ * @author aniefer
+ */
+public class CPPTemplateTemplateParameter extends CPPTemplateParameter implements
+ ICPPTemplateTemplateParameter, ICPPClassType {
+
+ private ICPPTemplateParameter [] templateParameters = null;
+
+ /**
+ * @param name
+ */
+ public CPPTemplateTemplateParameter(IASTName name) {
+ super(name);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getTemplateParameters()
+ */
+ public ICPPTemplateParameter[] getTemplateParameters() {
+ if( templateParameters == null ){
+ ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent();
+ ICPPASTTemplateParameter [] params = template.getTemplateParameters();
+ ICPPTemplateParameter p = null;
+ ICPPTemplateParameter [] result = null;
+ for (int i = 0; i < params.length; i++) {
+ if( params[i] instanceof ICPPASTSimpleTypeTemplateParameter ){
+ p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter)params[i]).getName().resolveBinding();
+ } else if( params[i] instanceof ICPPASTParameterDeclaration ) {
+ p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration)params[i]).getDeclarator().getName().resolveBinding();
+ } else if( params[i] instanceof ICPPASTTemplatedTypeTemplateParameter ){
+ p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter)params[i]).getName().resolveBinding();
+ }
+
+ if( p != null ){
+ result = (ICPPTemplateParameter[]) ArrayUtil.append( ICPPTemplateParameter.class, result, p );
+ }
+ }
+ templateParameters = (ICPPTemplateParameter[]) ArrayUtil.trim( ICPPTemplateParameter.class, result );
+ }
+ return templateParameters;
+ }
+
+ /**
+ * @param templateParameter
+ * @return
+ */
+ public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) {
+ IASTName name = CPPTemplates.getTemplateParameterName( templateParameter );
+
+ IBinding binding = name.getBinding();
+ if( binding == null ){
+ //create a new binding and set it for the corresponding parameter in all known decls
+ if( templateParameter instanceof ICPPASTSimpleTypeTemplateParameter )
+ binding = new CPPTemplateTypeParameter( name );
+ else if( templateParameter instanceof ICPPASTParameterDeclaration )
+ binding = new CPPTemplateNonTypeParameter( name );
+ else
+ binding = new CPPTemplateTemplateParameter( name );
+ name.setBinding( binding );
+ }
+ return binding;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getTemplateSpecializations()
+ */
+ public ICPPTemplateSpecialization[] getTemplateSpecializations() throws DOMException {
+ return ICPPTemplateSpecialization.EMPTY_TEMPLATE_SPECIALIZATION_ARRAY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter#getDefault()
+ */
+ public IType getDefault() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
+ */
+ public ICPPBase[] getBases() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFields()
+ */
+ public IField[] getFields() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#findField(java.lang.String)
+ */
+ public IField findField(String name) throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
+ */
+ public ICPPField[] getDeclaredFields() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
+ */
+ public ICPPMethod[] getMethods() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
+ */
+ public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
+ */
+ public ICPPMethod[] getDeclaredMethods() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
+ */
+ public ICPPConstructor[] getConstructors() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
+ */
+ public IBinding[] getFriends() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
+ */
+ public int getKey() throws DOMException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope()
+ */
+ public IScope getCompositeScope() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName)
+ */
+ public ICPPDelegate createDelegate(IASTName name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDefinition(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
+ */
+ public void addDeclaration(IASTNode node) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
+ */
+ public boolean isSameType( IType type ) {
+ if( type == this )
+ return true;
+ if( type instanceof ITypedef )
+ return ((ITypedef)type).isSameType( this );
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java
new file mode 100644
index 00000000000..ad3ae769b5a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTypeParameter.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 13, 2005
+ */
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
+
+/**
+ * @author aniefer
+ */
+public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
+ ICPPTemplateTypeParameter, IType {
+
+ /**
+ * @param name
+ */
+ public CPPTemplateTypeParameter(IASTName name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter#getDefault()
+ */
+ public IType getDefault() throws DOMException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
+ */
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
+ */
+ public boolean isSameType( IType type ) {
+ if( type == this )
+ return true;
+ if( type instanceof ITypedef )
+ return ((ITypedef)type).isSameType( this );
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java
index da33d8a878d..33017d876d5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java
@@ -17,18 +17,30 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IArrayType;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IPointerType;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IQualifierType;
+import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
@@ -40,18 +52,26 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.core.parser.util.ObjectSet;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
+import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics.Cost;
/**
* @author aniefer
@@ -90,8 +110,11 @@ public class CPPTemplates {
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) decl;
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
if( dtors.length == 0 ){
- if( simpleDecl.getDeclSpecifier() instanceof ICPPASTCompositeTypeSpecifier ){
- name = ((ICPPASTCompositeTypeSpecifier)simpleDecl.getDeclSpecifier()).getName();
+ IASTDeclSpecifier spec = simpleDecl.getDeclSpecifier();
+ if( spec instanceof ICPPASTCompositeTypeSpecifier ){
+ name = ((ICPPASTCompositeTypeSpecifier)spec).getName();
+ } else if( spec instanceof ICPPASTElaboratedTypeSpecifier ){
+ name = ((ICPPASTElaboratedTypeSpecifier)spec).getName();
}
} else {
IASTDeclarator dtor = dtors[0];
@@ -126,6 +149,9 @@ public class CPPTemplates {
} else {
binding = name.resolveBinding();
}
+ } else if( parent instanceof ICPPASTTemplatedTypeTemplateParameter ){
+ ICPPASTTemplatedTypeTemplateParameter templatedParam = (ICPPASTTemplatedTypeTemplateParameter) parent;
+ binding = templatedParam.getName().resolveBinding();
}
return (binding instanceof ICPPTemplateDefinition) ? (ICPPTemplateDefinition) binding : null;
}
@@ -135,6 +161,8 @@ public class CPPTemplates {
IBinding binding = null;
if( template instanceof CPPTemplateDefinition ){
binding = ((CPPTemplateDefinition)template).resolveTemplateParameter( templateParameter );
+ } else if( template instanceof CPPTemplateTemplateParameter ){
+ binding = ((CPPTemplateTemplateParameter)template).resolveTemplateParameter( templateParameter );
}
return binding;
@@ -159,26 +187,67 @@ public class CPPTemplates {
*/
public static IBinding createBinding(ICPPASTTemplateId id) {
IASTNode parent = id.getParent();
- if( parent instanceof ICPPASTCompositeTypeSpecifier ){
+ int segment = -1;
+ if( parent instanceof ICPPASTQualifiedName ){
+ IASTName [] ns = ((ICPPASTQualifiedName)parent).getNames();
+ segment = ( ns[ ns.length - 1 ] == id ) ? 1 : 0;
+ parent = parent.getParent();
+ }
+
+ if( parent instanceof ICPPASTCompositeTypeSpecifier && segment == 1 ){
return createClassPartialSpecialization( (ICPPASTCompositeTypeSpecifier) parent );
+ } else if( parent instanceof ICPPASTFunctionDeclarator && segment == 1 ){
+ return createFunctionSpecialization( id );
}
- IASTName templateName = id.getTemplateName();
- IBinding template = templateName.resolveBinding();
- if( template != null && template instanceof ICPPTemplateDefinition ){
- return ((CPPTemplateDefinition)template).instantiate( id );
+
+ //a reference: class or function template?
+ IBinding template = null;
+ if( parent instanceof ICPPASTNamedTypeSpecifier || segment == 0 ){
+ //class template
+ IASTName templateName = id.getTemplateName();
+ template = templateName.resolveBinding();
+ if( template instanceof ICPPTemplateSpecialization ){
+ //specializations are selected during the instantiation, start with the primary template
+ try {
+ template = ((ICPPTemplateSpecialization)template).getPrimaryTemplateDefinition();
+ } catch (DOMException e) {
+ return e.getProblem();
+ }
+ }
+
+ if( template != null && template instanceof ICPPTemplateDefinition ){
+ if( template instanceof CPPTemplateDefinition )
+ if( template instanceof ICPPTemplateTemplateParameter ){
+ return template;//todo
+ } else if( template instanceof CPPTemplateDefinition )
+ return ((CPPTemplateDefinition)template).instantiate( id );
+ }
+ } else {
+ //functions are instatiated as part of the resolution process
+ template = CPPVisitor.createBinding( id );
+ if( template instanceof ICPPTemplateInstance ){
+ IASTName templateName = id.getTemplateName();
+ templateName.setBinding( ((ICPPTemplateInstance)template).getOriginalBinding() );
+ }
}
+
return template;
}
protected static IBinding createClassPartialSpecialization( ICPPASTCompositeTypeSpecifier compSpec ){
- ICPPASTTemplateId id = (ICPPASTTemplateId) compSpec.getName();
+ IASTName name = compSpec.getName();
+ if( name instanceof ICPPASTQualifiedName ){
+ IASTName [] ns = ((ICPPASTQualifiedName)name).getNames();
+ name = ns[ ns.length - 1 ];
+ }
+ ICPPASTTemplateId id = (ICPPASTTemplateId) name;
IBinding binding = id.getTemplateName().resolveBinding();
if( !(binding instanceof ICPPClassTemplate) )
return null; //TODO: problem?
CPPClassTemplate template = (CPPClassTemplate) binding;
- ICPPTemplateSpecialization [] specializations = template.getSpecializations();
+ ICPPTemplateSpecialization [] specializations = template.getTemplateSpecializations();
ICPPTemplateSpecialization spec = null;
for (int i = 0; i < specializations.length; i++) {
if( isSameTemplate( specializations[i], id ) ){
@@ -196,6 +265,165 @@ public class CPPTemplates {
template.addSpecialization( spec );
return spec;
}
+
+ protected static IBinding createFunctionSpecialization( IASTName name ){
+ CPPSemantics.LookupData data = new CPPSemantics.LookupData( name );
+ data.forceQualified = true;
+ IScope scope = CPPVisitor.getContainingScope( name );
+ if( name.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME ){
+ try {
+ scope = scope.getParent();
+ } catch (DOMException e) {
+ }
+ }
+ try {
+ CPPSemantics.lookup( data, scope );
+ } catch (DOMException e) {
+ return e.getProblem();
+ }
+
+ ICPPFunctionTemplate function = resolveTemplateFunctions( (Object[]) data.foundItems, name );
+ if( function == null )
+ return new ProblemBinding( name, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, name.toCharArray() );
+ if( function instanceof IProblemBinding )
+ return function;
+
+ if( name instanceof ICPPASTTemplateId ){
+ ((ICPPASTTemplateId)name).getTemplateName().setBinding( function );
+ }
+ IASTNode parent = name.getParent();
+ while( parent instanceof IASTName )
+ parent = parent.getParent();
+
+ ICPPTemplateSpecialization spec = new CPPFunctionTemplateSpecialization( (ICPPASTFunctionDeclarator)parent, function );
+ ((CPPTemplateDefinition)function).addSpecialization( spec );
+ return spec;
+ }
+
+ static protected ICPPFunctionTemplate resolveTemplateFunctions( Object [] items, IASTName name ) {
+ if( items == null )
+ return null;
+ ICPPFunctionTemplate [] templates = null;
+ IBinding temp = null;
+ for( int i = 0; i < items.length; i++ ){
+ Object o = items[i];
+
+ if( o instanceof IASTName ){
+ temp = ((IASTName) o).resolveBinding();
+ if( temp == null )
+ continue;
+ } else if( o instanceof IBinding ){
+ temp = (IBinding) o;
+ } else
+ continue;
+
+ if( temp instanceof ICPPTemplateInstance )
+ temp = ((ICPPTemplateInstance)temp).getOriginalBinding();
+ if( temp instanceof ICPPFunctionTemplate )
+ templates = (ICPPFunctionTemplate[]) ArrayUtil.append( ICPPFunctionTemplate.class, templates, temp );
+ }
+
+ if( templates == null )
+ return null;
+
+ IType [] templateArguments = null;
+
+ if( name instanceof ICPPASTTemplateId ){
+ templateArguments = createTypeArray( ((ICPPASTTemplateId)name).getTemplateArguments() );
+ }
+ int numArgs = ( templateArguments != null ) ? templateArguments.length : 0;
+
+
+ if( name.getParent() instanceof IASTName )
+ name = (IASTName) name.getParent();
+ ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) name.getParent();
+ IType [] functionParameters = createTypeArray( fdtor.getParameters() );
+
+ ICPPFunctionTemplate result = null;
+ outer: for( int i = 0; i < templates.length && templates[i] != null; i++ ){
+ ICPPFunctionTemplate tmpl = templates[i];
+
+ ObjectMap map = ObjectMap.EMPTY_MAP;
+ try {
+ map = deduceTemplateArguments( tmpl, functionParameters );
+ } catch (DOMException e) {
+ }
+
+ if( map == null )
+ continue;
+ ICPPTemplateParameter [] params = null;
+ try {
+ params = tmpl.getTemplateParameters();
+ } catch (DOMException e) {
+ continue;
+ }
+
+ int numParams = params.length;
+ IType arg = null;
+ for( int j = 0; j < numParams; j++ ){
+ ICPPTemplateParameter param = params[j];
+ if( j < numArgs ){
+ arg = templateArguments[j];
+ }
+ if( map.containsKey( param ) ) {
+ IType t = (IType) map.get( param );
+ if( arg == null )
+ arg = t;
+ else if( !t.isSameType( arg ) ){
+ continue outer;
+ }
+ } else if( arg == null || !matchTemplateParameterAndArgument( param, arg )){
+ continue outer;
+ }
+ }
+ //made it this far, its a match
+ if( result != null ){
+ return new CPPFunctionTemplate.CPPFunctionTemplateProblem(name, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, name.toCharArray() );
+ }
+ result = tmpl;
+ }
+
+ return result;
+ }
+
+ static protected IType[] deduceTemplateFunctionArguments( ICPPTemplateSpecialization specialization, IASTNode [] specArgs ) throws DOMException
+ {
+ if( !(specialization instanceof ICPPFunction ) )
+ return null;
+
+ ICPPFunctionTemplate primaryTemplate = (ICPPFunctionTemplate) specialization.getPrimaryTemplateDefinition();
+ ICPPTemplateParameter [] templateParameters = primaryTemplate.getTemplateParameters();
+ IType [] arguments = createTypeArray( specArgs );
+
+ IType [] result = new IType[ templateParameters.length ];
+ ObjectMap map = null;
+
+ for( int i = 0; i < templateParameters.length; i++ ){
+ ICPPTemplateParameter param = templateParameters[i];
+ IType arg = null;
+ if( i < arguments.length ){
+ arg = arguments[i];
+ } else {
+ if( map == null ){
+ IParameter [] functionParameters = ((ICPPFunction)specialization).getParameters();
+ IType [] paramTypes = createTypeArray( functionParameters );
+ map = deduceTemplateArguments( primaryTemplate, paramTypes );
+ if(map == null )
+ return null;
+ }
+ if( map.containsKey( param ) ){
+ arg = (IType) map.get( param );
+ }
+ }
+
+ if( arg == null || !matchTemplateParameterAndArgument( param, arg ) )
+ return null;
+
+ result[i] = arg;
+ }
+
+ return result;
+ }
/**
* @param scope
* @return
@@ -210,16 +438,16 @@ public class CPPTemplates {
* @param arguments
* @return
*/
- public static IBinding createInstance( IASTName id, ICPPScope scope, IBinding decl, ObjectMap argMap) {
+ public static IBinding createInstance( ICPPScope scope, IBinding decl, ObjectMap argMap, IType [] args ) {
ICPPTemplateInstance instance = null;
if( decl instanceof ICPPClassType ){
- instance = new CPPClassInstance( id, scope, decl, argMap );
+ instance = new CPPClassInstance( scope, decl, argMap, args );
} else if( decl instanceof ICPPField ){
- instance = new CPPFieldInstance( scope, decl, argMap );
+ instance = new CPPFieldInstance( scope, decl, argMap, args );
} else if( decl instanceof ICPPMethod ) {
- instance = new CPPMethodInstance( scope, decl, argMap );
+ instance = new CPPMethodInstance( scope, decl, argMap, args );
} else if( decl instanceof ICPPFunction ) {
- instance = new CPPFunctionInstance( scope, decl, argMap );
+ instance = new CPPFunctionInstance( scope, decl, argMap, args );
}
return instance;
}
@@ -260,9 +488,13 @@ public class CPPTemplates {
temp = (IType) type.clone();
((ITypeContainer)temp).setType( newType );
newType = temp;
+ } else {
+ newType = type;
}
} else if( type instanceof ICPPTemplateParameter && argMap.containsKey( type ) ){
newType = (IType) argMap.get( type );
+ } else if( type instanceof CPPDeferredClassInstance ){
+ newType = ((CPPDeferredClassInstance)type).instantiate( argMap );
}
return newType;
@@ -272,8 +504,11 @@ public class CPPTemplates {
if( name == null ) return null;
IASTNode parent = name.getParent();
- while( !(parent instanceof ICPPASTTemplateDeclaration) )
+ while( parent != null && !(parent instanceof ICPPASTTemplateDeclaration) &&
+ !(parent instanceof ICPPASTTemplatedTypeTemplateParameter) )
+ {
parent = parent.getParent();
+ }
if( parent == null ) return null;
@@ -298,14 +533,16 @@ public class CPPTemplates {
++i;
}
if( ns[j] == name ){
- if( i <= idx )
- return templates[ i - 1 ];
- break;
+ if( i < idx )
+ return templates[ i ];
+ return null;
}
}
} else {
return templates[0];
}
+ } else if( parent instanceof ICPPASTTemplatedTypeTemplateParameter ){
+
}
return null;
@@ -333,7 +570,12 @@ public class CPPTemplates {
* @return
*/
public static boolean isSameTemplate(ICPPTemplateDefinition definition, IASTName name) {
- ICPPTemplateParameter [] defParams = definition.getTemplateParameters();
+ ICPPTemplateParameter [] defParams = null;
+ try {
+ defParams = definition.getTemplateParameters();
+ } catch (DOMException e1) {
+ return false;
+ }
ICPPASTTemplateDeclaration templateDecl = getTemplateDeclaration( name );
ICPPASTTemplateParameter [] templateParams = templateDecl.getTemplateParameters();
if( defParams.length != templateParams.length )
@@ -353,11 +595,21 @@ public class CPPTemplates {
boolean result = false;
IASTNode parent = name.getParent();
if( parent instanceof ICPPASTFunctionDeclarator ){
- IType type = CPPVisitor.createType( (IASTDeclarator) parent );
try {
- IType ftype = ((ICPPFunction)definition).getType();
- if( ftype.isSameType( type ) )
- result = true;
+ IASTParameterDeclaration [] params = ((ICPPASTFunctionDeclarator)parent).getParameters();
+ IParameter [] ps = ((ICPPFunction)definition).getParameters();
+ if( ps.length == params.length ) {
+ int i = 0;
+ for(; i < ps.length; i++) {
+ IType t1 = CPPVisitor.createType( params[i].getDeclarator() );
+ IType t2 = ps[0].getType();
+ if( ! t1.isSameType( t2 ) ){
+ break;
+ }
+ }
+ if( i == ps.length )
+ result = true;
+ }
} catch (DOMException e) {
}
} else if( parent instanceof IASTDeclSpecifier ){
@@ -365,10 +617,16 @@ public class CPPTemplates {
if( definition instanceof ICPPTemplateSpecialization ){
ICPPTemplateSpecialization spec = (ICPPTemplateSpecialization) definition;
IASTNode [] args = ((ICPPASTTemplateId)name).getTemplateArguments();
- if( args.length == spec.getArguments().length ){
+ IType [] specArgs = null;
+ try {
+ specArgs = spec.getArguments();
+ } catch (DOMException e) {
+ result = false;
+ }
+ if( specArgs != null && args.length == specArgs.length ){
int i = 0;
for (; i < args.length; i++) {
- IType t1 = CPPVisitor.createType( spec.getArguments()[i] );
+ IType t1 = specArgs[i];
IType t2 = CPPVisitor.createType( args[i] );
if( t1 != null && t2 != null && t1.isSameType( t2 ) )
continue;
@@ -390,20 +648,527 @@ public class CPPTemplates {
return result;
}
+ static public IType [] createTypeArray( Object [] params ){
+ if( params instanceof IType[] )
+ return (IType[]) params;
+
+ IType [] result = new IType[ params.length ];
+ for( int i = 0; i < params.length; i++ ) {
+ if( params[i] instanceof IASTNode ){
+ result[i] = CPPVisitor.createType( (IASTNode) params[ i ] );
+ }
+ }
+ return result;
+ }
+
static protected IFunction[] selectTemplateFunctions( ObjectSet templates, Object[] functionArguments, IASTName name ) {//IASTNode[] templateArguments ){
+ if( templates == null || templates.size() == 0 )
+ return null;
+
IFunction [] instances = null;
- if( name.getParent() instanceof ICPPASTTemplateId )
- name = (IASTName) name.getParent();
- if( name instanceof ICPPASTTemplateId ){
- Object [] keys = templates.keyArray();
- for (int i = 0; i < keys.length; i++) {
- CPPTemplateDefinition templateDef = (CPPTemplateDefinition) keys[i];
- ICPPTemplateInstance temp = (ICPPTemplateInstance) templateDef.instantiate( (ICPPASTTemplateId) name );
- if( temp != null )
- instances = (IFunction[]) ArrayUtil.append( IFunction.class, instances, temp );
+
+ int size = templates.size();
+
+ int numTemplateArgs = 0;
+ IASTNode [] templateArguments = null;
+ if( name instanceof ICPPASTTemplateId ) {
+ templateArguments = ((ICPPASTTemplateId)name).getTemplateArguments();
+ numTemplateArgs = templateArguments.length;
+ }
+
+ IType [] fnArgs = createTypeArray( functionArguments );
+
+ outer: for( int idx = 0; idx < size; idx++ ){
+ CPPFunctionTemplate template = (CPPFunctionTemplate) templates.keyAt( idx );
+
+ ObjectMap map = null;
+ try {
+ map = deduceTemplateArguments( template, fnArgs );
+ } catch (DOMException e) {
+ continue;
}
+ if( map == null )
+ continue;
+
+ ICPPTemplateParameter [] templateParams = template.getTemplateParameters();
+ int numTemplateParams = templateParams.length;
+
+ IType [] instanceArgs = null;
+ for( int i = 0; i < numTemplateParams; i++ ){
+ IType arg = ( i < numTemplateArgs ) ? CPPVisitor.createType( templateArguments[i] ) : null;
+ IType mapped = (IType) map.get( templateParams[i] );
+
+ if( arg != null && mapped != null )
+ if( arg.isSameType( mapped ) )
+ instanceArgs = (IType[]) ArrayUtil.append( IType.class, instanceArgs, arg );
+ else
+ continue outer;
+ else if( arg == null && mapped == null )
+ continue outer;
+ else
+ instanceArgs = (IType[]) ArrayUtil.append( IType.class, instanceArgs, (arg != null) ? arg : mapped );
+ }
+ instanceArgs = (IType[]) ArrayUtil.trim( IType.class, instanceArgs );
+ ICPPTemplateInstance temp = (ICPPTemplateInstance) template.instantiate( instanceArgs );
+ if( temp != null )
+ instances = (IFunction[]) ArrayUtil.append( IFunction.class, instances, temp );
}
- return instances;
- //TODO, instead of the above, do proper argument checking, deduction
+
+ return (IFunction[]) ArrayUtil.trim( IFunction.class, instances );
+ }
+
+ /**
+ *
+ * @param template
+ * @param args
+ * @return
+ *
+ * A type that is specified in terms of template parameters (P) is compared with an actual
+ * type (A), and an attempt is made to find template argument vaules that will make P,
+ * after substitution of the deduced values, compatible with A.
+ * @throws DOMException
+ */
+ static private ObjectMap deduceTemplateArguments( ICPPFunctionTemplate template, IType[] arguments ) throws DOMException{
+ ICPPFunction function = (ICPPFunction) template;
+ IParameter [] functionParameters = null;
+ try {
+ functionParameters = function.getParameters();
+ } catch (DOMException e) {
+ return null;
+ }
+ if( arguments == null /*|| functionParameters.length != arguments.length*/ ){
+ return null;
+ }
+
+ int numParams = functionParameters.length;
+ int numArgs = arguments.length;
+ ObjectMap map = new ObjectMap(numParams);
+ for( int i = 0; i < numArgs && i < numParams; i++ ){
+ if( !deduceTemplateArgument( map, functionParameters[i].getType(), arguments[i] ) ){
+ return null;
+ }
+ }
+
+ return map;
+ }
+
+ /**
+ * 14.8.2.1-2 If P is a cv-qualified type, the top level cv-qualifiers of P's type are ignored for type
+ * deduction. If P is a reference type, the type referred to by P is used for Type deduction.
+ * @param pSymbol
+ * @return
+ */
+ static private IType getParameterTypeForDeduction( IType pType ){
+ IType result = pType;
+ try {
+ if( pType instanceof IQualifierType ){
+ result = ((IQualifierType)pType).getType();
+ } else if( pType instanceof ICPPReferenceType ){
+ result = ((ICPPReferenceType)pType).getType();
+ } else if( pType instanceof CPPPointerType ){
+ result = ((CPPPointerType)pType).stripQualifiers();
+ }
+ } catch ( DOMException e ){
+ result = e.getProblem();
+ }
+ return result;
+ }
+
+ /**
+ * 14.8.2.1-2
+ * if P is not a reference type
+ * - If A is an array type, the pointer type produced by the array-to-pointer conversion is used instead
+ * - If A is a function type, the pointer type produced by the function-to-pointer conversion is used instead
+ * - If A is a cv-qualified type, the top level cv-qualifiers are ignored for type deduction
+ * @param aInfo
+ * @return
+ */
+ static private IType getArgumentTypeForDeduction( IType aType, boolean pIsAReferenceType ) {
+ IType result = aType;
+ if( !pIsAReferenceType ){
+ try {
+ if( aType instanceof IArrayType ){
+ result = new CPPPointerType( ((IArrayType)aType).getType() );
+ } else if( aType instanceof IFunctionType ){
+ result = new CPPPointerType( aType );
+ } else if( aType instanceof IQualifierType ){
+ result = ((IQualifierType)aType).getType();
+ } else if( aType instanceof CPPPointerType ){
+ result = ((CPPPointerType)aType).stripQualifiers();
+ }
+ } catch( DOMException e ){
+ result = e.getProblem();
+ }
+ }
+
+ return result;
+ }
+
+ static private boolean expressionsEquivalent( IASTExpression p, IASTExpression a ){
+ if( p == null )
+ return true;
+
+ if( p instanceof IASTLiteralExpression && a instanceof IASTLiteralExpression ){
+ return p.toString().equals( a.toString () );
+ }
+ return false;
+ }
+ static protected boolean deduceTemplateArgument( ObjectMap map, IType p, IType a ) throws DOMException {
+ boolean pIsAReferenceType = ( p instanceof ICPPReferenceType );
+ p = getParameterTypeForDeduction( p );
+ a = getArgumentTypeForDeduction( a, pIsAReferenceType );
+
+ if( p instanceof IBasicType ) {
+ if( p.isSameType( a ) && a instanceof IBasicType ) {
+ return expressionsEquivalent( ((IBasicType)p).getValue(), ((IBasicType)a).getValue() );
+ }
+ } else {
+ while( p != null ){
+ if( p instanceof IBasicType ){
+ return p.isSameType( a );
+ } else if( p instanceof ICPPPointerToMemberType ){
+ if( !(a instanceof ICPPPointerToMemberType ) )
+ return false;
+
+ if( !deduceTemplateArgument( map, ((ICPPPointerToMemberType)p).getMemberOfClass(), ((ICPPPointerToMemberType)a).getMemberOfClass() ) )
+ return false;
+
+ p = ((ICPPPointerToMemberType)p).getType();
+ p = ((ICPPPointerToMemberType)a).getType();
+ } else if( p instanceof IPointerType ){
+ if( !(a instanceof IPointerType) ){
+ return false;
+ }
+ p = ((IPointerType) p).getType();
+ a = ((IPointerType) a).getType();
+ } else if ( p instanceof IQualifierType ){
+ if( !(a instanceof IQualifierType) )
+ return false;
+ a = ((IQualifierType)a).getType(); //TODO a = strip qualifiers from p out of a
+ p = ((IQualifierType)p).getType();
+ } else if( p instanceof IFunctionType ){
+ if( !(a instanceof IFunctionType ) )
+ return false;
+ if( !deduceTemplateArgument( map, ((IFunctionType)p).getReturnType(), ((IFunctionType)a).getReturnType() ) )
+ return false;
+ IType [] pParams = ((IFunctionType)p).getParameterTypes();
+ IType [] aParams = ((IFunctionType)a).getParameterTypes();
+ if( pParams.length != aParams.length )
+ return false;
+ for (int i = 0; i < pParams.length; i++) {
+ if( !deduceTemplateArgument( map, pParams[i], aParams[i] ) )
+ return false;
+ }
+ } else if( p instanceof ICPPTemplateParameter ){
+ if( map.containsKey( p ) ){
+ IType current = (IType)map.get( p );
+ return current.isSameType( a );
+ }
+ if( a == null )
+ return false;
+ map.put( p, a );
+ return true;
+ } else if( p instanceof ICPPTemplateInstance ){
+ if( !(a instanceof ICPPTemplateInstance ) )
+ return false;
+ ICPPTemplateInstance pInst = (ICPPTemplateInstance) p;
+ ICPPTemplateInstance aInst = (ICPPTemplateInstance) a;
+
+ IType [] pArgs = createTypeArray( pInst.getArguments() );
+ IType [] aArgs = createTypeArray( aInst.getArguments() );
+ if( pArgs.length != aArgs.length )
+ return false;
+ for (int i = 0; i < pArgs.length; i++) {
+ if( !deduceTemplateArgument( map, pArgs[i], aArgs[i] ) )
+ return false;
+ }
+ return true;
+ } else {
+ return p.isSameType( a );
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * transform a function template for use in partial ordering, as described in the
+ * spec 14.5.5.2-3
+ * @param template
+ * @return
+ * -for each type template parameter, synthesize a unique type and substitute that for each
+ * occurence of that parameter in the function parameter list
+ * -for each non-type template parameter, synthesize a unique value of the appropriate type and
+ * susbstitute that for each occurence of that parameter in the function parameter list
+ * for each template template parameter, synthesize a unique class template and substitute that
+ * for each occurence of that parameter in the function parameter list
+ * @throws DOMException
+ */
+
+ static private IType [] createArgsForFunctionTemplateOrdering( ICPPFunctionTemplate template ) throws DOMException{
+ ICPPTemplateParameter [] paramList = template.getTemplateParameters();
+ int size = paramList.length;
+ IType [] args = new IType [ size ];
+ for( int i = 0; i < size; i++ ){
+ ICPPTemplateParameter param = paramList[i];
+ if( param instanceof ICPPTemplateNonTypeParameter ){
+ IType t = ((ICPPTemplateNonTypeParameter)param).getType();
+ if( t instanceof CPPBasicType ){
+ CPPASTLiteralExpression exp = new CPPASTLiteralExpression();
+ exp.setValue( String.valueOf( i ) );
+ CPPBasicType temp = (CPPBasicType) t.clone();
+ temp.setValue( exp );
+ args[i] = temp;
+ }
+ } else {
+ args[i] = new CPPBasicType( -1, 0 );
+ }
+ }
+ return args;
+ }
+
+ static protected int orderTemplateFunctions( ICPPFunctionTemplate f1, ICPPFunctionTemplate f2 ) throws DOMException {
+ //Using the transformed parameter list, perform argument deduction against the other
+ //function template
+ IType [] args = createArgsForFunctionTemplateOrdering( f1 );
+ ICPPFunction function = (ICPPFunction) ((CPPTemplateDefinition)f1).instantiate( args );
+
+ ObjectMap m1 = deduceTemplateArguments( f2, function.getType().getParameterTypes() );
+
+ args = createArgsForFunctionTemplateOrdering( f2 );
+ function = (ICPPFunction) ((CPPTemplateDefinition)f2).instantiate( args );
+
+ ObjectMap m2 = deduceTemplateArguments( f1, function.getType().getParameterTypes() );
+
+ //The transformed template is at least as specialized as the other iff the deduction
+ //succeeds and the deduced parameter types are an exact match
+ //A template is more specialized than another iff it is at least as specialized as the
+ //other template and that template is not at least as specialized as the first.
+ boolean d1 = ( m1 != null );
+ boolean d2 = ( m2 != null );
+
+ if( d1 && d2 || !d1 && !d2 )
+ return 0;
+ else if( d1 && !d2 )
+ return 1;
+ else
+ return -1;
+ }
+
+ static protected ICPPTemplateDefinition matchTemplatePartialSpecialization( ICPPTemplateDefinition template, IType[] args ) throws DOMException{
+ if( template == null ){
+ return null;
+ }
+
+ ICPPTemplateSpecialization[] specializations = template.getTemplateSpecializations();
+ int size = ( specializations != null ) ? specializations.length : 0;
+ if( size == 0 ){
+ return template;
+ }
+
+ ICPPTemplateSpecialization bestMatch = null, spec = null;
+ boolean bestMatchIsBest = true;
+ IType[] specArgs = null;
+ for( int i = 0; i < size; i++ ){
+ spec = specializations[i];
+ specArgs = spec.getArguments();
+ if( specArgs == null || specArgs.length != args.length ){
+ continue;
+ }
+
+ int specArgsSize = specArgs.length;
+ ObjectMap map = new ObjectMap(specArgsSize);
+ IType t1 = null, t2 = null;
+
+ boolean match = true;
+ for( int j = 0; j < specArgsSize; j++ ){
+ t1 = specArgs[j];
+ t2 = args[j];
+
+ if( !deduceTemplateArgument( map, t1, t2 ) ){
+ match = false;
+ break;
+ }
+ }
+ if( match ){
+ int compare = orderSpecializations( bestMatch, spec );
+ if( compare == 0 ){
+ bestMatchIsBest = false;
+ } else if( compare < 0 ) {
+ bestMatch = spec;
+ bestMatchIsBest = true;
+ }
+ }
+ }
+
+ //14.5.4.1 If none of the specializations is more specialized than all the other matchnig
+ //specializations, then the use of the class template is ambiguous and the program is ill-formed.
+ if( !bestMatchIsBest ){
+ //TODO problem
+ return new CPPTemplateDefinition.CPPTemplateProblem( null, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, null);
+ }
+
+ return bestMatch;
+ }
+
+ /**
+ * Compare spec1 to spec2. Return > 0 if spec1 is more specialized, < 0 if spec2
+ * is more specialized, = 0 otherwise.
+ * @param spec1
+ * @param spec2
+ * @return
+ * @throws DOMException
+ */
+ static private int orderSpecializations( ICPPTemplateSpecialization spec1, ICPPTemplateSpecialization spec2 ) throws DOMException {
+ if( spec1 == null ){
+ return -1;
+ }
+
+ //to order class template specializations, we need to transform them into function templates
+ ICPPFunctionTemplate template1 = null, template2 = null;
+
+ if( spec1 instanceof ICPPClassType ) {
+ template1 = classTemplateSpecializationToFunctionTemplate( spec1 );
+ template2 = classTemplateSpecializationToFunctionTemplate( spec2 );
+ } else if( spec1 instanceof ICPPFunction ) {
+ template1 = (ICPPFunctionTemplate) spec1;
+ template2 = (ICPPFunctionTemplate) spec2;
+ }
+
+ return orderTemplateFunctions( template1, template2);
+ }
+
+ public static final class CPPImplicitFunctionTemplate extends CPPFunctionTemplate {
+ IParameter [] functionParameters = null;
+ ICPPTemplateParameter [] templateParameters = null;
+ /**
+ * @param name
+ */
+ public CPPImplicitFunctionTemplate( ICPPTemplateParameter [] templateParameters, IParameter [] functionParameters) {
+ super( null );
+ this.functionParameters = functionParameters;
+ this.templateParameters = templateParameters;
+ }
+ public IParameter[] getParameters() {
+ return functionParameters;
+ }
+ public ICPPTemplateParameter[] getTemplateParameters() {
+ return templateParameters;
+ }
+ public IScope getScope() {
+ return null;
+ }
+ public IFunctionType getType() {
+ if( type == null ){
+ type = CPPVisitor.createImplicitFunctionType( new CPPBasicType(IBasicType.t_void, 0 ), functionParameters );
+ }
+ return type;
+ }
+ }
+ /**
+ * transform the class template to a function template as described in the spec
+ * 14.5.4.2-1
+ * @param template
+ * @return IParameterizedSymbol
+ * the function template has the same template parameters as the partial specialization and
+ * has a single function parameter whose type is a class template specialization with the template
+ * arguments of the partial specialization
+ */
+ static private ICPPFunctionTemplate classTemplateSpecializationToFunctionTemplate( ICPPTemplateSpecialization specialization ) {
+ if( !(specialization instanceof ICPPClassType) )
+ return null;
+
+ ICPPTemplateDefinition template = specialization;
+ IType [] args = null;
+ try {
+ args = specialization.getArguments();
+ } catch (DOMException e1) {
+ return null;
+ }
+
+ IType paramType = (IType) ((CPPTemplateDefinition)template).instantiate( args );
+ IParameter [] functionParameters = new IParameter[] { new CPPParameter( paramType ) };
+
+ try {
+ return new CPPImplicitFunctionTemplate( specialization.getTemplateParameters(), functionParameters );
+ } catch (DOMException e) {
+ return null;
+ }
+ }
+
+ static private boolean isValidArgument(ICPPTemplateParameter param, IType argument) {
+ //TODO
+ return true;
+ }
+ static protected boolean matchTemplateParameterAndArgument( ICPPTemplateParameter param, IType argument ){
+ if( !isValidArgument(param, argument) ){
+ return false;
+ }
+ if( param instanceof ICPPTemplateTypeParameter )
+ return true;
+ else if( param instanceof ICPPTemplateTemplateParameter ){
+ if( !( argument instanceof ICPPTemplateDefinition ) )
+ return false;
+
+ ICPPTemplateParameter [] pParams = null, aParams = null;
+ try {
+ pParams = ((ICPPTemplateTemplateParameter)param).getTemplateParameters();
+ aParams = ((ICPPTemplateDefinition)argument).getTemplateParameters();
+ } catch ( DOMException e ) {
+ return false;
+ }
+
+
+ int size = pParams.length;
+ if( aParams.length != size){
+ return false;
+ }
+
+ for( int i = 0; i < size; i++){
+ if( (pParams[i] instanceof ICPPTemplateTypeParameter && !(aParams[i] instanceof ICPPTemplateTypeParameter)) ||
+ (pParams[i] instanceof ICPPTemplateTemplateParameter && !(aParams[i] instanceof ICPPTemplateTemplateParameter)) ||
+ (pParams[i] instanceof ICPPTemplateNonTypeParameter && !(aParams[i] instanceof ICPPTemplateNonTypeParameter)) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ } else {
+ try {
+ IType pType = ((ICPPTemplateNonTypeParameter)param).getType();
+ Cost cost = CPPSemantics.checkStandardConversionSequence( argument, pType );
+
+ if( cost == null || cost.rank == Cost.NO_MATCH_RANK ){
+ return false;
+ }
+ } catch( DOMException e ){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static IBinding instantiateWithinClassTemplate( ICPPClassTemplate template ) throws DOMException {
+ IType [] args = null;
+ if( template instanceof ICPPTemplateSpecialization ){
+ args = ((ICPPTemplateSpecialization)template).getArguments();
+ } else {
+ ICPPTemplateParameter [] templateParameters = template.getTemplateParameters();
+ args = new IType [ templateParameters.length ];
+ for (int i = 0; i < templateParameters.length; i++) {
+ if( templateParameters[i] instanceof IType ){
+ args[i] = (IType) templateParameters[i];
+ } else if( templateParameters[i] instanceof ICPPTemplateNonTypeParameter ){
+ args[i] = ((ICPPTemplateNonTypeParameter)templateParameters[i]).getType();
+ }
+ }
+ }
+
+ if( template instanceof CPPClassTemplate ){
+ return ((CPPClassTemplate)template).instantiate( args );
+ }
+ return template;
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java
index 573a9c67c32..e86cceb3125 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java
@@ -94,6 +94,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
@@ -110,6 +111,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
@@ -286,7 +288,17 @@ public class CPPVisitor {
if( mustBeSimple && elabType.getName() instanceof ICPPASTQualifiedName )
return binding;
+ boolean template = false;
ICPPScope scope = (ICPPScope) getContainingScope( name );
+ if( scope instanceof ICPPTemplateScope ){
+ ICPPScope parentScope = null;
+ try {
+ template = true;
+ parentScope = (ICPPScope) scope.getParent();
+ } catch (DOMException e1) {
+ }
+ scope = parentScope;
+ }
if( mustBeSimple ){
//3.3.1-5 ... the identifier is declared in the smallest non-class non-function-prototype scope that contains
@@ -309,11 +321,14 @@ public class CPPVisitor {
binding = scope.getBinding( elabType.getName(), false );
if( binding == null || !(binding instanceof ICPPClassType) ){
if( elabType.getKind() != IASTElaboratedTypeSpecifier.k_enum ){
- binding = new CPPClassType( elabType.getName() );
+ if( template )
+ binding = new CPPClassTemplate( name );
+ else
+ binding = new CPPClassType( name );
scope.addName( elabType.getName() );
}
- } else if( binding instanceof ICPPClassType ){
- ((CPPClassType)binding).addDeclaration( elabType );
+ } else if( binding instanceof ICPPInternalBinding ){
+ ((ICPPInternalBinding)binding).addDeclaration( elabType );
}
} catch ( DOMException e ) {
binding = e.getProblem();
@@ -343,13 +358,14 @@ public class CPPVisitor {
return CPPTemplates.createClassPartialSpecialization( compType );
}
try {
- binding = scope.getBinding( name, false );
+ binding = (scope != null ) ? scope.getBinding( name, false ) : null;
if( binding == null || !(binding instanceof ICPPClassType) ){
if( template )
binding = new CPPClassTemplate( name );
else
binding = new CPPClassType( name );
- scope.addName( compType.getName() );
+ if( scope != null )
+ scope.addName( compType.getName() );
} else {
if( binding instanceof ICPPInternalBinding ){
ICPPInternalBinding internal = (ICPPInternalBinding) binding;
@@ -409,10 +425,10 @@ public class CPPVisitor {
}
private static IBinding createBinding( IASTDeclarator declarator ){
IASTNode parent = declarator.getParent();
+ while( parent instanceof IASTDeclarator ){
+ parent = parent.getParent();
+ }
- if( parent instanceof IASTTypeId )
- return CPPSemantics.resolveBinding( declarator.getName() );
-
while( declarator.getNestedDeclarator() != null )
declarator = declarator.getNestedDeclarator();
@@ -422,8 +438,10 @@ public class CPPVisitor {
name = ns[ ns.length - 1 ];
}
- while( parent instanceof IASTDeclarator ){
- parent = parent.getParent();
+ if( parent instanceof IASTTypeId )
+ return CPPSemantics.resolveBinding( name );
+ else if( parent.getPropertyInParent() == ICPPASTTemplateSpecialization.OWNED_DECLARATION ){
+ return CPPTemplates.createFunctionSpecialization( name );
}
boolean template = false;
@@ -629,7 +647,9 @@ public class CPPVisitor {
return dtor.getFunctionScope();
else if( prop == IASTFunctionDefinition.DECLARATOR )
return ((IASTCompoundStatement)((IASTFunctionDefinition)dtor.getParent()).getBody()).getScope();
- } //else if( node instanceof ICPPASTTemplateDeclaration )
+ } else if( parent instanceof ICPPASTTemplateDeclaration ){
+ return CPPTemplates.getContainingScope( node );
+ }
} else if( node instanceof IASTInitializerExpression ){
IASTNode parent = node.getParent();
while( !(parent instanceof IASTDeclarator) )
@@ -1350,6 +1370,8 @@ public class CPPVisitor {
return getExpressionType( (IASTExpression) node );
if( node instanceof IASTTypeId )
return createType( ((IASTTypeId) node).getAbstractDeclarator() );
+ if( node instanceof IASTParameterDeclaration )
+ return createType( ((IASTParameterDeclaration)node).getDeclarator() );
return null;
}
/**
@@ -1420,6 +1442,14 @@ public class CPPVisitor {
IBinding binding = name.resolveBinding();
if( binding instanceof IType )
type = (IType) binding;
+ else if( binding instanceof ICPPTemplateNonTypeParameter ){
+ //TODO workaround... is there anything better?
+ try {
+ type = ((ICPPTemplateNonTypeParameter)binding).getType();
+ } catch (DOMException e) {
+ type = e.getProblem();
+ }
+ }
}
return type;
}
@@ -1442,6 +1472,8 @@ public class CPPVisitor {
return (IType) binding;
} else if( binding instanceof IFunction ){
return ((IFunction)binding).getType();
+ } else if( binding instanceof ICPPTemplateNonTypeParameter ){
+ return ((ICPPTemplateNonTypeParameter)binding).getType();
}
} catch ( DOMException e ){
return e.getProblem();
@@ -1490,17 +1522,16 @@ public class CPPVisitor {
}
case ICPPASTLiteralExpression.lk_true :
case ICPPASTLiteralExpression.lk_false:
- return new CPPBasicType( ICPPBasicType.t_bool, 0 );
+ return new CPPBasicType( ICPPBasicType.t_bool, 0, expression );
case IASTLiteralExpression.lk_char_constant:
- return new CPPBasicType( IBasicType.t_char, 0 );
+ return new CPPBasicType( IBasicType.t_char, 0, expression );
case IASTLiteralExpression.lk_float_constant:
- return new CPPBasicType( IBasicType.t_float, 0 );
+ return new CPPBasicType( IBasicType.t_float, 0, expression );
case IASTLiteralExpression.lk_integer_constant:
- return new CPPBasicType( IBasicType.t_int, 0 );
+ return new CPPBasicType( IBasicType.t_int, 0, expression );
case IASTLiteralExpression.lk_string_literal:
- IType type = new CPPBasicType( IBasicType.t_char, 0 );
+ IType type = new CPPBasicType( IBasicType.t_char, 0, expression );
type = new CPPQualifierType( type, true, false );
- ((CPPQualifierType)type).setFromStringLiteral( true );
return new CPPPointerType( type );
}
@@ -1526,6 +1557,20 @@ public class CPPVisitor {
} catch( DOMException e ){
return e.getProblem();
}
+ } else if( binding instanceof ITypedef ){
+ try {
+ IType type = ((ITypedef)binding).getType();
+ while( type instanceof ITypedef )
+ type = ((ITypedef)type).getType();
+ if( type instanceof IFunctionType ){
+ return ((IFunctionType)type).getReturnType();
+ }
+ return type;
+ } catch (DOMException e) {
+ return e.getProblem();
+ }
+ } else if( binding instanceof IProblemBinding ){
+ return (IType) binding;
}
} else if( expression instanceof IASTBinaryExpression ){
IASTBinaryExpression binary = (IASTBinaryExpression) expression;
@@ -1541,6 +1586,8 @@ public class CPPVisitor {
}
}
return new ProblemBinding( binary, IProblemBinding.SEMANTIC_INVALID_TYPE, new char[0] );
+ } else if( type instanceof CPPBasicType ){
+ ((CPPBasicType)type).setValue( expression );
}
return type;
}
@@ -1556,6 +1603,8 @@ public class CPPVisitor {
}
} else if( op == IASTUnaryExpression.op_amper ){
return new CPPPointerType( type );
+ } else if ( type instanceof CPPBasicType ){
+ ((CPPBasicType)type).setValue( expression );
}
return type;
} else if( expression instanceof ICPPASTFieldReference ){
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java
index f62b8559a23..f9418ba204d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerToMemberType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -34,6 +34,19 @@ public class GPPPointerToMemberType extends CPPPointerToMemberType implements
this.isRestrict = operator.isRestrict();
}
+ public IType stripQualifiers(){
+ GPPPointerToMemberType result = (GPPPointerToMemberType) super.stripQualifiers();
+
+ if( isRestrict ){
+ if( result == this ){
+ result = (GPPPointerToMemberType) clone();
+ result.isRestrict = false;
+ } else {
+ result.isRestrict = false;
+ }
+ }
+ return result;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPPointerType#isRestrict()
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java
index 66c78bae217..0f9f233afd3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GPPPointerType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
@@ -43,6 +43,20 @@ public class GPPPointerType extends CPPPointerType implements IGPPPointerType {
super( type, isConst, isVolatile );
this.isRestrict = isRestrict;
}
+
+ public IType stripQualifiers(){
+ GPPPointerType result = (GPPPointerType) super.stripQualifiers();
+
+ if( isRestrict ){
+ if( result == this ){
+ result = (GPPPointerType) clone();
+ result.isRestrict = false;
+ } else {
+ result.isRestrict = false;
+ }
+ }
+ return result;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer#isRestrict()

Back to the top