mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed Bug 81739 - [GNUCSourceParser] Lookahead problem w/nested declarators
This commit is contained in:
parent
55f4eca137
commit
78f1bf9054
9 changed files with 615 additions and 514 deletions
|
@ -290,81 +290,6 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
[--Start Example(CPP 11.3-2):
|
|
||||||
class A {
|
|
||||||
public:
|
|
||||||
int z;
|
|
||||||
int z1;
|
|
||||||
};
|
|
||||||
class B : public A {
|
|
||||||
int a;
|
|
||||||
public:
|
|
||||||
int b, c;
|
|
||||||
int bf();
|
|
||||||
protected:
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
class D : private B {
|
|
||||||
int d;
|
|
||||||
public:
|
|
||||||
B::c; //adjust access to B::c
|
|
||||||
B::z; //adjust access to A::z
|
|
||||||
A::z1; //adjust access to A::z1
|
|
||||||
int e;
|
|
||||||
int df();
|
|
||||||
protected:
|
|
||||||
B::x; //adjust access to B::x
|
|
||||||
int g;
|
|
||||||
};
|
|
||||||
class X : public D {
|
|
||||||
int xf();
|
|
||||||
};
|
|
||||||
int ef(D&);
|
|
||||||
int ff(X&);
|
|
||||||
--End Example]
|
|
||||||
*/
|
|
||||||
public void test11_3s2() throws Exception { //bug 92793
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
buffer.append("class A {\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("public:\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int z;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int z1;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("class B : public A {\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int a;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("public:\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int b, c;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int bf();\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("protected:\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int x;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int y;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("class D : private B {\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int d;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("public:\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("B::c; //adjust access to B::c\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("B::z; //adjust access to A::z\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("A::z1; //adjust access to A::z1\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int e;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int df();\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("protected:\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("B::x; //adjust access to B::x\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int g;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("class X : public D {\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int xf();\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int ef(D&);\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int ff(X&);\n"); //$NON-NLS-1$
|
|
||||||
try {
|
|
||||||
parse(buffer.toString(), ParserLanguage.CPP, true, 0);
|
|
||||||
assertTrue(false);
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
[--Start Example(CPP 14.3-2):
|
[--Start Example(CPP 14.3-2):
|
||||||
template<class T> void f();
|
template<class T> void f();
|
||||||
|
|
|
@ -6095,7 +6095,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
buffer.append("friend class X;\n"); //$NON-NLS-1$
|
buffer.append("friend class X;\n"); //$NON-NLS-1$
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
buffer.append("class X : A::B { // illformed:\n"); //$NON-NLS-1$
|
buffer.append("class X : A::B { // illformed:\n"); //$NON-NLS-1$
|
||||||
buffer.append("A::B cannot be accessed\n"); //$NON-NLS-1$
|
buffer.append("//A::B cannot be accessed\n"); //$NON-NLS-1$
|
||||||
buffer.append("// in the baseclause for X\n"); //$NON-NLS-1$
|
buffer.append("// in the baseclause for X\n"); //$NON-NLS-1$
|
||||||
buffer.append("A::B mx; // OK: A::B used to declare member of X\n"); //$NON-NLS-1$
|
buffer.append("A::B mx; // OK: A::B used to declare member of X\n"); //$NON-NLS-1$
|
||||||
buffer.append("class Y : A::B { // OK: A::B used to declare member of X\n"); //$NON-NLS-1$
|
buffer.append("class Y : A::B { // OK: A::B used to declare member of X\n"); //$NON-NLS-1$
|
||||||
|
@ -9981,7 +9981,7 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
buffer.append("void f() {\n"); //$NON-NLS-1$
|
buffer.append("void f() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("g(1); //calls g(double)\n"); //$NON-NLS-1$
|
buffer.append("g(1); //calls g(double)\n"); //$NON-NLS-1$
|
||||||
buffer.append("h++; //illformed:\n"); //$NON-NLS-1$
|
buffer.append("h++; //illformed:\n"); //$NON-NLS-1$
|
||||||
buffer.append("cannot increment function;\n"); //$NON-NLS-1$
|
buffer.append("// cannot increment function;\n"); //$NON-NLS-1$
|
||||||
buffer.append("// this could be diagnosed either here or\n"); //$NON-NLS-1$
|
buffer.append("// this could be diagnosed either here or\n"); //$NON-NLS-1$
|
||||||
buffer.append("// at the point of instantiation\n"); //$NON-NLS-1$
|
buffer.append("// at the point of instantiation\n"); //$NON-NLS-1$
|
||||||
buffer.append("}\n"); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
|
@ -12442,5 +12442,74 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
parse(buffer.toString(), ParserLanguage.CPP, false, 0);
|
parse(buffer.toString(), ParserLanguage.CPP, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
[--Start Example(CPP 11.3-2):
|
||||||
|
class A {
|
||||||
|
public:
|
||||||
|
int z;
|
||||||
|
int z1;
|
||||||
|
};
|
||||||
|
class B : public A {
|
||||||
|
int a;
|
||||||
|
public:
|
||||||
|
int b, c;
|
||||||
|
int bf();
|
||||||
|
protected:
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
};
|
||||||
|
class D : private B {
|
||||||
|
int d;
|
||||||
|
public:
|
||||||
|
B::c; //adjust access to B::c
|
||||||
|
B::z; //adjust access to A::z
|
||||||
|
A::z1; //adjust access to A::z1
|
||||||
|
int e;
|
||||||
|
int df();
|
||||||
|
protected:
|
||||||
|
B::x; //adjust access to B::x
|
||||||
|
int g;
|
||||||
|
};
|
||||||
|
class X : public D {
|
||||||
|
int xf();
|
||||||
|
};
|
||||||
|
int ef(D&);
|
||||||
|
int ff(X&);
|
||||||
|
--End Example]
|
||||||
|
*/
|
||||||
|
public void test11_3s2() throws Exception { //bug 92793
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("class A {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("public:\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int z;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int z1;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class B : public A {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int a;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("public:\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int b, c;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int bf();\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("protected:\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int x;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int y;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class D : private B {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int d;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("public:\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("B::c; //adjust access to B::c\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("B::z; //adjust access to A::z\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("A::z1; //adjust access to A::z1\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int e;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int df();\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("protected:\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("B::x; //adjust access to B::x\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int g;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("class X : public D {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int xf();\n"); //$NON-NLS-1$
|
||||||
|
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, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
|
@ -58,6 +59,7 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
|
@ -3487,7 +3489,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
buffer.append(" const C& operator+=(const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator+=(const C&);\n"); //$NON-NLS-1$
|
||||||
buffer.append(" const C& operator -= (const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator -= (const C&);\n"); //$NON-NLS-1$
|
||||||
buffer.append(" const C& operator *= (const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator *= (const C&);\n"); //$NON-NLS-1$
|
||||||
buffer.append(" cosnt C& operator /= (const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator /= (const C&);\n"); //$NON-NLS-1$
|
||||||
buffer.append(" const C& operator %= (const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator %= (const C&);\n"); //$NON-NLS-1$
|
||||||
buffer.append(" const C& operator^=(const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator^=(const C&);\n"); //$NON-NLS-1$
|
||||||
buffer.append(" const C& operator&= (const C&);\n"); //$NON-NLS-1$
|
buffer.append(" const C& operator&= (const C&);\n"); //$NON-NLS-1$
|
||||||
|
@ -4085,6 +4087,124 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame( f1, col.getName(4).resolveBinding() );
|
assertSame( f1, col.getName(4).resolveBinding() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testAmbiguity() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("class A { };\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int f() { \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" A * b = 0;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" A & c = 0;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("}"); //$NON-NLS-1$
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
|
IASTFunctionDefinition f = (IASTFunctionDefinition) tu
|
||||||
|
.getDeclarations()[1];
|
||||||
|
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
|
||||||
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
IASTDeclarationStatement ds = (IASTDeclarationStatement) body
|
||||||
|
.getStatements()[i];
|
||||||
|
String s1 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ds
|
||||||
|
.getDeclaration()).getDeclSpecifier()).getName().toString();
|
||||||
|
String s2 = ((IASTCompositeTypeSpecifier) A.getDeclSpecifier())
|
||||||
|
.getName().toString();
|
||||||
|
assertEquals(s1, s2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug84696() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("struct A {\n int a; \n};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct B: virtual A { };\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct C: B { };\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct D: B { };\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct E: public C, public D { };\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct F: public A { };\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("void f() {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("E e;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("e.B::a = 0;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("F f;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("f.A::a = 1;\n}\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.accept(col);
|
||||||
|
|
||||||
|
assertEquals(col.size(), 26);
|
||||||
|
|
||||||
|
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
|
ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
|
||||||
|
|
||||||
|
assertNotNull(A);
|
||||||
|
assertNotNull(B);
|
||||||
|
|
||||||
|
assertInstances(col, A, 4);
|
||||||
|
assertInstances(col, B, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBasicPointerToMember() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer("class X {\n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" public:\n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" void f(int);\n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" int a;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int X:: * pmi = &X::a;\n"); //$NON-NLS-1$
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
assertEquals(tu.getDeclarations().length, 2);
|
||||||
|
IASTSimpleDeclaration p2m = (IASTSimpleDeclaration) tu
|
||||||
|
.getDeclarations()[1];
|
||||||
|
IASTDeclarator d = p2m.getDeclarators()[0];
|
||||||
|
ICPPASTPointerToMember po = (ICPPASTPointerToMember) d
|
||||||
|
.getPointerOperators()[0];
|
||||||
|
assertEquals(po.getName().toString(), "X::"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug84466() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("struct B {};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("struct D : B {};\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("void foo(D* dp)\n{\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("B* bp = dynamic_cast<B*>(dp);\n}\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTInitializerExpression) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
||||||
|
.getDeclarations()[2]).getBody()).getStatements()[0])
|
||||||
|
.getDeclaration()).getDeclarators()[0].getInitializer())
|
||||||
|
.getExpression();
|
||||||
|
|
||||||
|
assertEquals(dynamic_cast.getOperator(),
|
||||||
|
ICPPASTCastExpression.op_dynamic_cast);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug88338_CPP() throws Exception {
|
||||||
|
IASTTranslationUnit tu = parse(
|
||||||
|
"struct A; struct A* a;", ParserLanguage.CPP); //$NON-NLS-1$
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.accept(col);
|
||||||
|
|
||||||
|
assertTrue(col.getName(0).isDeclaration());
|
||||||
|
assertFalse(col.getName(0).isReference());
|
||||||
|
assertTrue(col.getName(1).isReference());
|
||||||
|
assertFalse(col.getName(1).isDeclaration());
|
||||||
|
|
||||||
|
tu = parse("struct A* a;", ParserLanguage.CPP); //$NON-NLS-1$
|
||||||
|
col = new CPPNameCollector();
|
||||||
|
tu.accept(col);
|
||||||
|
|
||||||
|
assertTrue(col.getName(0).isDeclaration());
|
||||||
|
assertFalse(col.getName(0).isReference());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPointerToFunction_CPP() throws Exception
|
||||||
|
{
|
||||||
|
IASTTranslationUnit tu = parse("int (*pfi)();", ParserLanguage.CPP); //$NON-NLS-1$
|
||||||
|
assertEquals(tu.getDeclarations().length, 1);
|
||||||
|
IASTSimpleDeclaration d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
||||||
|
assertEquals(d.getDeclarators().length, 1);
|
||||||
|
IASTStandardFunctionDeclarator f = (IASTStandardFunctionDeclarator) d.getDeclarators()[0];
|
||||||
|
assertEquals(f.getName().toString(), "");
|
||||||
|
assertNotNull(f.getNestedDeclarator());
|
||||||
|
assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
public void testBug95484() throws Exception {
|
public void testBug95484() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("class X { public: int bar; }; \n"); //$NON-NLS-1$
|
buffer.append("class X { public: int bar; }; \n"); //$NON-NLS-1$
|
||||||
|
|
|
@ -75,9 +75,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
|
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
|
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
|
import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.c.CFunction;
|
||||||
|
@ -160,7 +157,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTName name_ref_y = ref_y.getName();
|
IASTName name_ref_y = ref_y.getName();
|
||||||
assertEquals("y", name_ref_y.toString()); //$NON-NLS-1$
|
assertEquals("y", name_ref_y.toString()); //$NON-NLS-1$
|
||||||
|
|
||||||
//BINDINGS
|
// BINDINGS
|
||||||
// resolve the binding to get the variable object
|
// resolve the binding to get the variable object
|
||||||
IVariable var_x = (IVariable) name_x.resolveBinding();
|
IVariable var_x = (IVariable) name_x.resolveBinding();
|
||||||
assertEquals(globalScope, var_x.getScope());
|
assertEquals(globalScope, var_x.getScope());
|
||||||
|
@ -203,24 +200,32 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], name_y);
|
assertEquals(decls[0], name_y);
|
||||||
|
|
||||||
// // test clearBindings
|
// // test clearBindings
|
||||||
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()));
|
||||||
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
// //$NON-NLS-1$
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
||||||
// assertNotNull(((ICScope) body_f.getScope()).getBinding(
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()));
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray())); //$NON-NLS-1$
|
// //$NON-NLS-1$
|
||||||
// assertNotNull(((ICScope) body_f.getScope()).getBinding(
|
// assertNotNull(((ICScope) body_f.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray()));
|
||||||
// CVisitor.clearBindings(tu);
|
// //$NON-NLS-1$
|
||||||
// assertNull(((ICScope) tu.getScope()).getBinding(
|
// assertNotNull(((ICScope) body_f.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray()));
|
||||||
// assertNull(((ICScope) tu.getScope()).getBinding(
|
// //$NON-NLS-1$
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
// CVisitor.clearBindings(tu);
|
||||||
// assertNull(((ICScope) body_f.getScope()).getBinding(
|
// assertNull(((ICScope) tu.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()));
|
||||||
// assertNull(((ICScope) body_f.getScope()).getBinding(
|
// //$NON-NLS-1$
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray())); //$NON-NLS-1$
|
// assertNull(((ICScope) tu.getScope()).getBinding(
|
||||||
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()));
|
||||||
|
// //$NON-NLS-1$
|
||||||
|
// assertNull(((ICScope) body_f.getScope()).getBinding(
|
||||||
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("z").toCharArray()));
|
||||||
|
// //$NON-NLS-1$
|
||||||
|
// assertNull(((ICScope) body_f.getScope()).getBinding(
|
||||||
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray()));
|
||||||
|
// //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleStruct() throws Exception {
|
public void testSimpleStruct() throws Exception {
|
||||||
|
@ -244,8 +249,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(IASTDeclSpecifier.sc_typedef, type.getStorageClass());
|
assertEquals(IASTDeclSpecifier.sc_typedef, type.getStorageClass());
|
||||||
// this an anonymous struct
|
// this an anonymous struct
|
||||||
IASTName name_struct = type.getName();
|
IASTName name_struct = type.getName();
|
||||||
assertTrue( name_struct.isDeclaration() );
|
assertTrue(name_struct.isDeclaration());
|
||||||
assertFalse( name_struct.isReference() );
|
assertFalse(name_struct.isReference());
|
||||||
assertEquals("", name_struct.toString()); //$NON-NLS-1$
|
assertEquals("", name_struct.toString()); //$NON-NLS-1$
|
||||||
// member - x
|
// member - x
|
||||||
IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) type
|
IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) type
|
||||||
|
@ -298,7 +303,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getOperand2();
|
.getOperand2();
|
||||||
assertEquals("5", lit_5.toString()); //$NON-NLS-1$
|
assertEquals("5", lit_5.toString()); //$NON-NLS-1$
|
||||||
|
|
||||||
//Logical Bindings In Test
|
// Logical Bindings In Test
|
||||||
ICompositeType type_struct = (ICompositeType) name_struct
|
ICompositeType type_struct = (ICompositeType) name_struct
|
||||||
.resolveBinding();
|
.resolveBinding();
|
||||||
ITypedef typedef_S = (ITypedef) name_S.resolveBinding();
|
ITypedef typedef_S = (ITypedef) name_S.resolveBinding();
|
||||||
|
@ -453,7 +458,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
//struct A;
|
// struct A;
|
||||||
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1
|
IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1
|
||||||
|
@ -461,7 +466,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(0, decl1.getDeclarators().length);
|
assertEquals(0, decl1.getDeclarators().length);
|
||||||
IASTName nameA1 = compTypeSpec.getName();
|
IASTName nameA1 = compTypeSpec.getName();
|
||||||
|
|
||||||
//void f() {
|
// void f() {
|
||||||
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[1];
|
.getDeclarations()[1];
|
||||||
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef
|
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef
|
||||||
|
@ -489,7 +494,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(1, dtor.getPointerOperators().length);
|
assertEquals(1, dtor.getPointerOperators().length);
|
||||||
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
|
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
|
||||||
|
|
||||||
//bindings
|
// bindings
|
||||||
ICompositeType str1 = (ICompositeType) nameA1.resolveBinding();
|
ICompositeType str1 = (ICompositeType) nameA1.resolveBinding();
|
||||||
ICompositeType str2 = (ICompositeType) nameA2.resolveBinding();
|
ICompositeType str2 = (ICompositeType) nameA2.resolveBinding();
|
||||||
IVariable var = (IVariable) namea.resolveBinding();
|
IVariable var = (IVariable) namea.resolveBinding();
|
||||||
|
@ -536,7 +541,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
//struct A;
|
// struct A;
|
||||||
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1
|
IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1
|
||||||
|
@ -544,7 +549,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(0, decl1.getDeclarators().length);
|
assertEquals(0, decl1.getDeclarators().length);
|
||||||
IASTName nameA1 = compTypeSpec.getName();
|
IASTName nameA1 = compTypeSpec.getName();
|
||||||
|
|
||||||
//void f() {
|
// void f() {
|
||||||
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[1];
|
.getDeclarations()[1];
|
||||||
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef
|
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef
|
||||||
|
@ -563,7 +568,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(1, dtor.getPointerOperators().length);
|
assertEquals(1, dtor.getPointerOperators().length);
|
||||||
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
|
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
|
||||||
|
|
||||||
//bindings
|
// bindings
|
||||||
ICompositeType str1 = (ICompositeType) nameA1.resolveBinding();
|
ICompositeType str1 = (ICompositeType) nameA1.resolveBinding();
|
||||||
ICompositeType str2 = (ICompositeType) nameA2.resolveBinding();
|
ICompositeType str2 = (ICompositeType) nameA2.resolveBinding();
|
||||||
IVariable var = (IVariable) namea.resolveBinding();
|
IVariable var = (IVariable) namea.resolveBinding();
|
||||||
|
@ -603,7 +608,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
//struct A;
|
// struct A;
|
||||||
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) decl1
|
IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) decl1
|
||||||
|
@ -611,7 +616,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(0, decl1.getDeclarators().length);
|
assertEquals(0, decl1.getDeclarators().length);
|
||||||
IASTName name_A1 = elabTypeSpec.getName();
|
IASTName name_A1 = elabTypeSpec.getName();
|
||||||
|
|
||||||
//struct A * a;
|
// struct A * a;
|
||||||
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[1];
|
.getDeclarations()[1];
|
||||||
elabTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier();
|
elabTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier();
|
||||||
|
@ -621,7 +626,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(1, dtor.getPointerOperators().length);
|
assertEquals(1, dtor.getPointerOperators().length);
|
||||||
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
|
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
|
||||||
|
|
||||||
//struct A {
|
// struct A {
|
||||||
IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[2];
|
.getDeclarations()[2];
|
||||||
ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) decl3
|
ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) decl3
|
||||||
|
@ -634,7 +639,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
dtor = decl4.getDeclarators()[0];
|
dtor = decl4.getDeclarators()[0];
|
||||||
IASTName name_i = dtor.getName();
|
IASTName name_i = dtor.getName();
|
||||||
|
|
||||||
//void f() {
|
// void f() {
|
||||||
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[3];
|
.getDeclarations()[3];
|
||||||
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef
|
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef
|
||||||
|
@ -650,7 +655,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTName name_aref = id_a.getName();
|
IASTName name_aref = id_a.getName();
|
||||||
IASTName name_iref = fieldref.getFieldName();
|
IASTName name_iref = fieldref.getFieldName();
|
||||||
|
|
||||||
//bindings
|
// bindings
|
||||||
IVariable var_a1 = (IVariable) name_aref.resolveBinding();
|
IVariable var_a1 = (IVariable) name_aref.resolveBinding();
|
||||||
IVariable var_i1 = (IVariable) name_iref.resolveBinding();
|
IVariable var_i1 = (IVariable) name_iref.resolveBinding();
|
||||||
IPointerType structA_1pointer = (IPointerType) var_a1.getType();
|
IPointerType structA_1pointer = (IPointerType) var_a1.getType();
|
||||||
|
@ -772,23 +777,31 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], declaration2.getDeclarators()[0].getName());
|
assertEquals(decls[0], declaration2.getDeclarators()[0].getName());
|
||||||
|
|
||||||
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray()));
|
||||||
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
// //$NON-NLS-1$
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
// assertNotNull(((ICScope) tu.getScope()).getBinding(
|
||||||
// assertNotNull(((ICScope) compound.getScope()).getBinding(
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()));
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
// //$NON-NLS-1$
|
||||||
// assertNotNull(((ICScope) compound.getScope()).getBinding(
|
// assertNotNull(((ICScope) compound.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()));
|
||||||
// CVisitor.clearBindings(tu);
|
// //$NON-NLS-1$
|
||||||
// assertNull(((ICScope) tu.getScope()).getBinding(
|
// assertNotNull(((ICScope) compound.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray()));
|
||||||
// assertNull(((ICScope) tu.getScope()).getBinding(
|
// //$NON-NLS-1$
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray())); //$NON-NLS-1$
|
// CVisitor.clearBindings(tu);
|
||||||
// assertNull(((ICScope) compound.getScope()).getBinding(
|
// assertNull(((ICScope) tu.getScope()).getBinding(
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray())); //$NON-NLS-1$
|
// ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray()));
|
||||||
// assertNull(((ICScope) compound.getScope()).getBinding(
|
// //$NON-NLS-1$
|
||||||
// ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray())); //$NON-NLS-1$
|
// assertNull(((ICScope) tu.getScope()).getBinding(
|
||||||
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("f").toCharArray()));
|
||||||
|
// //$NON-NLS-1$
|
||||||
|
// assertNull(((ICScope) compound.getScope()).getBinding(
|
||||||
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()));
|
||||||
|
// //$NON-NLS-1$
|
||||||
|
// assertNull(((ICScope) compound.getScope()).getBinding(
|
||||||
|
// ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray()));
|
||||||
|
// //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionParameters() throws Exception {
|
public void testFunctionParameters() throws Exception {
|
||||||
|
@ -800,7 +813,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
//void f(
|
// void f(
|
||||||
IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
IASTStandardFunctionDeclarator dtor = (IASTStandardFunctionDeclarator) f_decl
|
IASTStandardFunctionDeclarator dtor = (IASTStandardFunctionDeclarator) f_decl
|
||||||
|
@ -811,7 +824,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTDeclarator paramDtor = param1.getDeclarator();
|
IASTDeclarator paramDtor = param1.getDeclarator();
|
||||||
IASTName name_param1 = paramDtor.getName();
|
IASTName name_param1 = paramDtor.getName();
|
||||||
|
|
||||||
//void f(
|
// void f(
|
||||||
IASTFunctionDefinition f_defn = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition f_defn = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[1];
|
.getDeclarations()[1];
|
||||||
assertTrue(f_defn.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
assertTrue(f_defn.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
||||||
|
@ -831,7 +844,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getExpression();
|
.getExpression();
|
||||||
IASTName name_param3 = idexp.getName();
|
IASTName name_param3 = idexp.getName();
|
||||||
|
|
||||||
//bindings
|
// bindings
|
||||||
IParameter param_1 = (IParameter) name_param3.resolveBinding();
|
IParameter param_1 = (IParameter) name_param3.resolveBinding();
|
||||||
IParameter param_2 = (IParameter) name_param2.resolveBinding();
|
IParameter param_2 = (IParameter) name_param2.resolveBinding();
|
||||||
IParameter param_3 = (IParameter) name_param1.resolveBinding();
|
IParameter param_3 = (IParameter) name_param1.resolveBinding();
|
||||||
|
@ -932,14 +945,14 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
//void f();
|
// void f();
|
||||||
IASTSimpleDeclaration fdecl = (IASTSimpleDeclaration) tu
|
IASTSimpleDeclaration fdecl = (IASTSimpleDeclaration) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) fdecl
|
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) fdecl
|
||||||
.getDeclarators()[0];
|
.getDeclarators()[0];
|
||||||
IASTName name_f = fdtor.getName();
|
IASTName name_f = fdtor.getName();
|
||||||
|
|
||||||
//void g() {
|
// void g() {
|
||||||
IASTFunctionDefinition gdef = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition gdef = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[1];
|
.getDeclarations()[1];
|
||||||
|
|
||||||
|
@ -954,14 +967,14 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTName name_fcall = fcall_id.getName();
|
IASTName name_fcall = fcall_id.getName();
|
||||||
assertNull(fcall.getParameterExpression());
|
assertNull(fcall.getParameterExpression());
|
||||||
|
|
||||||
//void f() {}
|
// void f() {}
|
||||||
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[2];
|
.getDeclarations()[2];
|
||||||
assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator);
|
||||||
fdtor = (IASTStandardFunctionDeclarator) fdef.getDeclarator();
|
fdtor = (IASTStandardFunctionDeclarator) fdef.getDeclarator();
|
||||||
IASTName name_fdef = fdtor.getName();
|
IASTName name_fdef = fdtor.getName();
|
||||||
|
|
||||||
//bindings
|
// bindings
|
||||||
IFunction function_1 = (IFunction) name_fcall.resolveBinding();
|
IFunction function_1 = (IFunction) name_fcall.resolveBinding();
|
||||||
IFunction function_2 = (IFunction) name_f.resolveBinding();
|
IFunction function_2 = (IFunction) name_f.resolveBinding();
|
||||||
IFunction function_3 = (IFunction) name_fdef.resolveBinding();
|
IFunction function_3 = (IFunction) name_fdef.resolveBinding();
|
||||||
|
@ -1002,7 +1015,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
//void f() {
|
// void f() {
|
||||||
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu
|
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[0];
|
.getDeclarations()[0];
|
||||||
IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody();
|
IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody();
|
||||||
|
@ -1036,7 +1049,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTIdExpression id_i3 = (IASTIdExpression) exprSt.getExpression();
|
IASTIdExpression id_i3 = (IASTIdExpression) exprSt.getExpression();
|
||||||
IASTName name_i4 = id_i3.getName();
|
IASTName name_i4 = id_i3.getName();
|
||||||
|
|
||||||
//bindings
|
// bindings
|
||||||
IVariable var_1 = (IVariable) name_i4.resolveBinding();
|
IVariable var_1 = (IVariable) name_i4.resolveBinding();
|
||||||
IVariable var_2 = (IVariable) name_i.resolveBinding();
|
IVariable var_2 = (IVariable) name_i.resolveBinding();
|
||||||
IVariable var_3 = (IVariable) name_i2.resolveBinding();
|
IVariable var_3 = (IVariable) name_i2.resolveBinding();
|
||||||
|
@ -1142,7 +1155,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
|
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
tu.accept( collector);
|
tu.accept(collector);
|
||||||
|
|
||||||
assertEquals(collector.size(), 3);
|
assertEquals(collector.size(), 3);
|
||||||
IFunction function = (IFunction) collector.getName(0).resolveBinding();
|
IFunction function = (IFunction) collector.getName(0).resolveBinding();
|
||||||
|
@ -1388,56 +1401,6 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.resolveBinding());
|
.resolveBinding());
|
||||||
assertEquals(decls.length, 1);
|
assertEquals(decls.length, 1);
|
||||||
assertEquals(decls[0], f.getNestedDeclarator().getName());
|
assertEquals(decls[0], f.getNestedDeclarator().getName());
|
||||||
|
|
||||||
tu = parse("int (*pfi)();", ParserLanguage.CPP); //$NON-NLS-1$
|
|
||||||
assertEquals(tu.getDeclarations().length, 1);
|
|
||||||
d = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
|
||||||
assertEquals(d.getDeclarators().length, 1);
|
|
||||||
f = (IASTStandardFunctionDeclarator) d.getDeclarators()[0];
|
|
||||||
assertEquals(f.getName().toString(), "");
|
|
||||||
assertNotNull(f.getNestedDeclarator());
|
|
||||||
assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBasicPointerToMember() throws Exception {
|
|
||||||
StringBuffer buffer = new StringBuffer("class X {\n"); //$NON-NLS-1$
|
|
||||||
buffer.append(" public:\n"); //$NON-NLS-1$
|
|
||||||
buffer.append(" void f(int);\n"); //$NON-NLS-1$
|
|
||||||
buffer.append(" int a;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int X:: * pmi = &X::a;\n"); //$NON-NLS-1$
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
|
||||||
assertEquals(tu.getDeclarations().length, 2);
|
|
||||||
IASTSimpleDeclaration p2m = (IASTSimpleDeclaration) tu
|
|
||||||
.getDeclarations()[1];
|
|
||||||
IASTDeclarator d = p2m.getDeclarators()[0];
|
|
||||||
ICPPASTPointerToMember po = (ICPPASTPointerToMember) d
|
|
||||||
.getPointerOperators()[0];
|
|
||||||
assertEquals(po.getName().toString(), "X::"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAmbiguity() throws Exception {
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
buffer.append("class A { };\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("int f() { \n"); //$NON-NLS-1$
|
|
||||||
buffer.append(" A * b = 0;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append(" A & c = 0;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("}"); //$NON-NLS-1$
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
|
||||||
IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[0];
|
|
||||||
IASTFunctionDefinition f = (IASTFunctionDefinition) tu
|
|
||||||
.getDeclarations()[1];
|
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
|
|
||||||
for (int i = 0; i < 2; ++i) {
|
|
||||||
IASTDeclarationStatement ds = (IASTDeclarationStatement) body
|
|
||||||
.getStatements()[i];
|
|
||||||
String s1 = ((IASTNamedTypeSpecifier) ((IASTSimpleDeclaration) ds
|
|
||||||
.getDeclaration()).getDeclSpecifier()).getName().toString();
|
|
||||||
String s2 = ((IASTCompositeTypeSpecifier) A.getDeclSpecifier())
|
|
||||||
.getName().toString();
|
|
||||||
assertEquals(s1, s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBasicTypes() throws Exception {
|
public void testBasicTypes() throws Exception {
|
||||||
|
@ -1712,7 +1675,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getDeclSpecifier();
|
.getDeclSpecifier();
|
||||||
ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding();
|
ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding();
|
||||||
IASTName name_A1 = elabSpec.getName();
|
IASTName name_A1 = elabSpec.getName();
|
||||||
assertTrue( name_A1.isDeclaration() );
|
assertTrue(name_A1.isDeclaration());
|
||||||
|
|
||||||
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
|
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
|
||||||
IFunction f = (IFunction) decl.getDeclarators()[0].getName()
|
IFunction f = (IFunction) decl.getDeclarators()[0].getName()
|
||||||
|
@ -1756,7 +1719,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertTrue(t_f_params[0] instanceof IBasicType);
|
assertTrue(t_f_params[0] instanceof IBasicType);
|
||||||
assertTrue(t_f_params[1] instanceof IBasicType);
|
assertTrue(t_f_params[1] instanceof IBasicType);
|
||||||
|
|
||||||
//g is a pointer to a function that returns void and has 1 parameter
|
// g is a pointer to a function that returns void and has 1 parameter
|
||||||
// struct A *
|
// struct A *
|
||||||
IType t_g = g.getType();
|
IType t_g = g.getType();
|
||||||
assertTrue(t_g instanceof IPointerType);
|
assertTrue(t_g instanceof IPointerType);
|
||||||
|
@ -1770,8 +1733,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
assertTrue(t_g_func_p1 instanceof IPointerType);
|
assertTrue(t_g_func_p1 instanceof IPointerType);
|
||||||
assertSame(((IPointerType) t_g_func_p1).getType(), A);
|
assertSame(((IPointerType) t_g_func_p1).getType(), A);
|
||||||
|
|
||||||
//h is a pointer to a function that returns a pointer to a function
|
// h is a pointer to a function that returns a pointer to a function
|
||||||
//the returned pointer to function returns void and takes 1 parameter
|
// the returned pointer to function returns void and takes 1 parameter
|
||||||
// int
|
// int
|
||||||
// the *h function takes 1 parameter struct A**
|
// the *h function takes 1 parameter struct A**
|
||||||
IType t_h = h.getType();
|
IType t_h = h.getType();
|
||||||
|
@ -1881,7 +1844,8 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
.getDesignators()[0]).getName();
|
.getDesignators()[0]).getName();
|
||||||
|
|
||||||
// test bug 87649
|
// test bug 87649
|
||||||
assertEquals(((ASTNode)(ICASTDesignatedInitializer) initializers1[0]).getLength(), 7);
|
assertEquals(((ASTNode) (ICASTDesignatedInitializer) initializers1[0])
|
||||||
|
.getLength(), 7);
|
||||||
|
|
||||||
IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1])
|
IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1])
|
||||||
.getDesignators()[0]).getName();
|
.getDesignators()[0]).getName();
|
||||||
|
@ -2513,7 +2477,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
IVariable a = (IVariable) col.getName(1).resolveBinding();
|
IVariable a = (IVariable) col.getName(1).resolveBinding();
|
||||||
assertNotNull(a);
|
assertNotNull(a);
|
||||||
|
@ -2534,7 +2498,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
IVariable a = (IVariable) col.getName(1).resolveBinding();
|
IVariable a = (IVariable) col.getName(1).resolveBinding();
|
||||||
IFunction g = (IFunction) col.getName(2).resolveBinding();
|
IFunction g = (IFunction) col.getName(2).resolveBinding();
|
||||||
|
@ -2557,7 +2521,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 9);
|
assertEquals(col.size(), 9);
|
||||||
IField x = (IField) col.getName(1).resolveBinding();
|
IField x = (IField) col.getName(1).resolveBinding();
|
||||||
|
@ -2579,7 +2543,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 6);
|
assertEquals(col.size(), 6);
|
||||||
IEnumerator one = (IEnumerator) col.getName(1).resolveBinding();
|
IEnumerator one = (IEnumerator) col.getName(1).resolveBinding();
|
||||||
|
@ -2602,17 +2566,19 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
IASTIfStatement if_statement = (IASTIfStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
||||||
.getDeclarations()[0]).getBody()).getStatements()[0];
|
.getDeclarations()[0]).getBody()).getStatements()[0];
|
||||||
assertEquals(((IASTBinaryExpression) if_statement.getConditionExpression())
|
assertEquals(((IASTBinaryExpression) if_statement
|
||||||
.getOperator(), IASTBinaryExpression.op_equals);
|
.getConditionExpression()).getOperator(),
|
||||||
|
IASTBinaryExpression.op_equals);
|
||||||
IASTIfStatement second_if_statement = (IASTIfStatement) if_statement
|
IASTIfStatement second_if_statement = (IASTIfStatement) if_statement
|
||||||
.getElseClause();
|
.getElseClause();
|
||||||
assertEquals(
|
assertEquals(((IASTBinaryExpression) second_if_statement
|
||||||
((IASTBinaryExpression) second_if_statement.getConditionExpression())
|
.getConditionExpression()).getOperator(),
|
||||||
.getOperator(), IASTBinaryExpression.op_lessThan);
|
IASTBinaryExpression.op_lessThan);
|
||||||
IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement
|
IASTIfStatement third_if_statement = (IASTIfStatement) second_if_statement
|
||||||
.getElseClause();
|
.getElseClause();
|
||||||
assertEquals(((IASTBinaryExpression) third_if_statement.getConditionExpression())
|
assertEquals(((IASTBinaryExpression) third_if_statement
|
||||||
.getOperator(), IASTBinaryExpression.op_greaterThan);
|
.getConditionExpression()).getOperator(),
|
||||||
|
IASTBinaryExpression.op_greaterThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug84090_LabelReferences() throws Exception {
|
public void testBug84090_LabelReferences() throws Exception {
|
||||||
|
@ -2626,7 +2592,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 3);
|
assertEquals(col.size(), 3);
|
||||||
ILabel end = (ILabel) col.getName(1).resolveBinding();
|
ILabel end = (ILabel) col.getName(1).resolveBinding();
|
||||||
|
@ -2643,7 +2609,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
tu.accept( collector);
|
tu.accept(collector);
|
||||||
|
|
||||||
assertEquals(collector.size(), 5);
|
assertEquals(collector.size(), 5);
|
||||||
IEnumeration col = (IEnumeration) collector.getName(0).resolveBinding();
|
IEnumeration col = (IEnumeration) collector.getName(0).resolveBinding();
|
||||||
|
@ -2657,7 +2623,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
IASTTranslationUnit tu = parse(
|
IASTTranslationUnit tu = parse(
|
||||||
"struct s { int a; } ss = { .a = 1 }; \n", ParserLanguage.C); //$NON-NLS-1$
|
"struct s { int a; } ss = { .a = 1 }; \n", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector collector = new CNameCollector();
|
CNameCollector collector = new CNameCollector();
|
||||||
tu.accept( collector);
|
tu.accept(collector);
|
||||||
|
|
||||||
assertEquals(collector.size(), 4);
|
assertEquals(collector.size(), 4);
|
||||||
IField a = (IField) collector.getName(1).resolveBinding();
|
IField a = (IField) collector.getName(1).resolveBinding();
|
||||||
|
@ -2683,7 +2649,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 3);
|
assertEquals(col.size(), 3);
|
||||||
IEnumeration e = (IEnumeration) col.getName(0).resolveBinding();
|
IEnumeration e = (IEnumeration) col.getName(0).resolveBinding();
|
||||||
|
@ -2703,7 +2669,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 3);
|
assertEquals(col.size(), 3);
|
||||||
IVariable p = (IVariable) col.getName(1).resolveBinding();
|
IVariable p = (IVariable) col.getName(1).resolveBinding();
|
||||||
|
@ -2724,7 +2690,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 3);
|
assertEquals(col.size(), 3);
|
||||||
|
|
||||||
|
@ -2755,7 +2721,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 7);
|
assertEquals(col.size(), 7);
|
||||||
|
|
||||||
|
@ -2775,7 +2741,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
public void testBug84266_2() throws Exception {
|
public void testBug84266_2() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("struct s f(void);", ParserLanguage.C); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse("struct s f(void);", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 3);
|
assertEquals(col.size(), 3);
|
||||||
|
|
||||||
|
@ -2784,7 +2750,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
tu = parse("struct s f(void){}", ParserLanguage.C); //$NON-NLS-1$
|
tu = parse("struct s f(void){}", ParserLanguage.C); //$NON-NLS-1$
|
||||||
col = new CNameCollector();
|
col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 3);
|
assertEquals(col.size(), 3);
|
||||||
|
|
||||||
|
@ -2804,7 +2770,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 6);
|
assertEquals(col.size(), 6);
|
||||||
|
|
||||||
|
@ -2831,7 +2797,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 11);
|
assertEquals(col.size(), 11);
|
||||||
|
|
||||||
|
@ -2860,7 +2826,7 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
assertEquals(col.size(), 13);
|
assertEquals(col.size(), 13);
|
||||||
|
|
||||||
|
@ -2894,135 +2860,79 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug84696() throws Exception {
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
buffer.append("struct A {\n int a; \n};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("struct B: virtual A { };\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("struct C: B { };\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("struct D: B { };\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("struct E: public C, public D { };\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("struct F: public A { };\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("void f() {\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("E e;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("e.B::a = 0;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("F f;\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("f.A::a = 1;\n}\n"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
|
||||||
tu.accept( col);
|
|
||||||
|
|
||||||
assertEquals(col.size(), 26);
|
|
||||||
|
|
||||||
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
|
|
||||||
ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
|
|
||||||
|
|
||||||
assertNotNull(A);
|
|
||||||
assertNotNull(B);
|
|
||||||
|
|
||||||
assertInstances(col, A, 4);
|
|
||||||
assertInstances(col, B, 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug85049() throws Exception {
|
public void testBug85049() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer("typedef int B;\n"); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer("typedef int B;\n"); //$NON-NLS-1$
|
||||||
buffer.append("void g() {\n"); //$NON-NLS-1$
|
buffer.append("void g() {\n"); //$NON-NLS-1$
|
||||||
buffer.append("B * bp; //1\n"); //$NON-NLS-1$
|
buffer.append("B * bp; //1\n"); //$NON-NLS-1$
|
||||||
buffer.append("}\n"); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
IASTTranslationUnit t = parse(buffer.toString(), ParserLanguage.C );
|
IASTTranslationUnit t = parse(buffer.toString(), ParserLanguage.C);
|
||||||
IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1];
|
||||||
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
IASTCompoundStatement body = (IASTCompoundStatement) g.getBody();
|
||||||
final IASTStatement statement = body.getStatements()[0];
|
final IASTStatement statement = body.getStatements()[0];
|
||||||
assertTrue(statement instanceof IASTDeclarationStatement);
|
assertTrue(statement instanceof IASTDeclarationStatement);
|
||||||
IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement)statement).getDeclaration();
|
IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statement)
|
||||||
assertTrue( bp.getDeclarators()[0].getName().resolveBinding() instanceof IVariable );
|
.getDeclaration();
|
||||||
|
assertTrue(bp.getDeclarators()[0].getName().resolveBinding() instanceof IVariable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug84466() throws Exception {
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
buffer.append("struct B {};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("struct D : B {};\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("void foo(D* dp)\n{\n"); //$NON-NLS-1$
|
|
||||||
buffer.append("B* bp = dynamic_cast<B*>(dp);\n}\n"); //$NON-NLS-1$
|
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
|
||||||
ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTInitializerExpression) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu
|
|
||||||
.getDeclarations()[2]).getBody()).getStatements()[0])
|
|
||||||
.getDeclaration()).getDeclarators()[0].getInitializer())
|
|
||||||
.getExpression();
|
|
||||||
|
|
||||||
assertEquals(dynamic_cast.getOperator(),
|
|
||||||
ICPPASTCastExpression.op_dynamic_cast);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug86766() throws Exception {
|
public void testBug86766() throws Exception {
|
||||||
IASTTranslationUnit tu = parse("char foo; void foo(){}", ParserLanguage.C); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(
|
||||||
|
"char foo; void foo(){}", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col);
|
tu.accept(col);
|
||||||
|
|
||||||
IVariable foo = (IVariable) col.getName(0).resolveBinding();
|
IVariable foo = (IVariable) col.getName(0).resolveBinding();
|
||||||
IProblemBinding prob = (IProblemBinding) col.getName(1).resolveBinding();
|
IProblemBinding prob = (IProblemBinding) col.getName(1)
|
||||||
assertEquals( prob.getID(), IProblemBinding.SEMANTIC_INVALID_OVERLOAD );
|
.resolveBinding();
|
||||||
assertNotNull( foo );
|
assertEquals(prob.getID(), IProblemBinding.SEMANTIC_INVALID_OVERLOAD);
|
||||||
|
assertNotNull(foo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug88338_CPP() throws Exception {
|
|
||||||
IASTTranslationUnit tu = parse( "struct A; struct A* a;", ParserLanguage.CPP ); //$NON-NLS-1$
|
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
|
||||||
tu.accept( col );
|
|
||||||
|
|
||||||
assertTrue( col.getName(0).isDeclaration() );
|
|
||||||
assertFalse( col.getName(0).isReference() );
|
|
||||||
assertTrue( col.getName(1).isReference() );
|
|
||||||
assertFalse( col.getName(1).isDeclaration() );
|
|
||||||
|
|
||||||
tu = parse( "struct A* a;", ParserLanguage.CPP ); //$NON-NLS-1$
|
|
||||||
col = new CPPNameCollector();
|
|
||||||
tu.accept( col );
|
|
||||||
|
|
||||||
assertTrue( col.getName(0).isDeclaration() );
|
|
||||||
assertFalse( col.getName(0).isReference() );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBug88338_C() throws Exception {
|
public void testBug88338_C() throws Exception {
|
||||||
IASTTranslationUnit tu = parse( "struct A; struct A* a;", ParserLanguage.C ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(
|
||||||
|
"struct A; struct A* a;", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CPPNameCollector col = new CPPNameCollector();
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
|
|
||||||
assertTrue( col.getName(0).isDeclaration() );
|
assertTrue(col.getName(0).isDeclaration());
|
||||||
assertFalse( col.getName(0).isReference() );
|
assertFalse(col.getName(0).isReference());
|
||||||
assertTrue( col.getName(1).isReference() );
|
assertTrue(col.getName(1).isReference());
|
||||||
assertFalse( col.getName(1).isDeclaration() );
|
assertFalse(col.getName(1).isDeclaration());
|
||||||
|
|
||||||
tu = parse( "struct A* a; struct A;", ParserLanguage.C ); //$NON-NLS-1$
|
tu = parse("struct A* a; struct A;", ParserLanguage.C); //$NON-NLS-1$
|
||||||
col = new CPPNameCollector();
|
col = new CPPNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
|
|
||||||
col.getName(2).resolveBinding();
|
col.getName(2).resolveBinding();
|
||||||
|
|
||||||
assertTrue( col.getName(0).isDeclaration() );
|
assertTrue(col.getName(0).isDeclaration());
|
||||||
assertFalse( col.getName(0).isReference() );
|
assertFalse(col.getName(0).isReference());
|
||||||
|
|
||||||
assertTrue( col.getName(2).isDeclaration() );
|
assertTrue(col.getName(2).isDeclaration());
|
||||||
assertFalse( col.getName(2).isReference() );
|
assertFalse(col.getName(2).isReference());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test88460() throws Exception {
|
public void test88460() throws Exception {
|
||||||
IASTTranslationUnit tu = parse( "void f();", ParserLanguage.C ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse("void f();", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
|
|
||||||
IFunction f = (IFunction) col.getName(0).resolveBinding();
|
IFunction f = (IFunction) col.getName(0).resolveBinding();
|
||||||
assertFalse( f.isStatic() );
|
assertFalse(f.isStatic());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug90253() throws Exception {
|
public void testBug90253() throws Exception {
|
||||||
IASTTranslationUnit tu = parse( "void f(int par) { int v1; };", ParserLanguage.C ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(
|
||||||
|
"void f(int par) { int v1; };", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
|
|
||||||
IFunction f = (IFunction) col.getName(0).resolveBinding();
|
IFunction f = (IFunction) col.getName(0).resolveBinding();
|
||||||
IParameter p = (IParameter) col.getName(1).resolveBinding();
|
IParameter p = (IParameter) col.getName(1).resolveBinding();
|
||||||
|
@ -3030,29 +2940,29 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IScope scope = f.getFunctionScope();
|
IScope scope = f.getFunctionScope();
|
||||||
|
|
||||||
IBinding [] bs = scope.find( "par" ); //$NON-NLS-1$
|
IBinding[] bs = scope.find("par"); //$NON-NLS-1$
|
||||||
assertEquals( bs.length, 1 );
|
assertEquals(bs.length, 1);
|
||||||
assertSame( bs[0], p );
|
assertSame(bs[0], p);
|
||||||
|
|
||||||
bs = scope.find( "v1" ); //$NON-NLS-1$
|
bs = scope.find("v1"); //$NON-NLS-1$
|
||||||
assertEquals( bs.length, 1 );
|
assertEquals(bs.length, 1);
|
||||||
assertSame( bs[0], v1 );
|
assertSame(bs[0], v1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFind() throws Exception {
|
public void testFind() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append( "struct S {}; \n"); //$NON-NLS-1$
|
buffer.append("struct S {}; \n"); //$NON-NLS-1$
|
||||||
buffer.append( "int S; \n"); //$NON-NLS-1$
|
buffer.append("int S; \n"); //$NON-NLS-1$
|
||||||
buffer.append( "void f( ) { \n"); //$NON-NLS-1$
|
buffer.append("void f( ) { \n"); //$NON-NLS-1$
|
||||||
buffer.append( " int S; \n"); //$NON-NLS-1$
|
buffer.append(" int S; \n"); //$NON-NLS-1$
|
||||||
buffer.append( " { \n"); //$NON-NLS-1$
|
buffer.append(" { \n"); //$NON-NLS-1$
|
||||||
buffer.append( " S : ; \n"); //$NON-NLS-1$
|
buffer.append(" S : ; \n"); //$NON-NLS-1$
|
||||||
buffer.append( " } \n"); //$NON-NLS-1$
|
buffer.append(" } \n"); //$NON-NLS-1$
|
||||||
buffer.append( "} \n"); //$NON-NLS-1$
|
buffer.append("} \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.C );
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
|
|
||||||
ICompositeType S1 = (ICompositeType) col.getName(0).resolveBinding();
|
ICompositeType S1 = (ICompositeType) col.getName(0).resolveBinding();
|
||||||
IVariable S2 = (IVariable) col.getName(1).resolveBinding();
|
IVariable S2 = (IVariable) col.getName(1).resolveBinding();
|
||||||
|
@ -3062,73 +2972,73 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IScope scope = f.getFunctionScope();
|
IScope scope = f.getFunctionScope();
|
||||||
|
|
||||||
IBinding [] bs = scope.find( "S" ); //$NON-NLS-1$
|
IBinding[] bs = scope.find("S"); //$NON-NLS-1$
|
||||||
|
|
||||||
assertNotNull( S2 );
|
assertNotNull(S2);
|
||||||
assertEquals( bs.length, 3 );
|
assertEquals(bs.length, 3);
|
||||||
assertSame( bs[0], S3 );
|
assertSame(bs[0], S3);
|
||||||
assertSame( bs[1], S1 );
|
assertSame(bs[1], S1);
|
||||||
assertSame( bs[2], S4 );
|
assertSame(bs[2], S4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test92791() throws Exception {
|
public void test92791() throws Exception {
|
||||||
IASTTranslationUnit tu = parse( "void f() { int x, y; x * y; }", ParserLanguage.C ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(
|
||||||
|
"void f() { int x, y; x * y; }", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector col = new CNameCollector();
|
CNameCollector col = new CNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
for( int i = 0; i < col.size(); ++i )
|
for (int i = 0; i < col.size(); ++i)
|
||||||
assertFalse( col.getName( i ).resolveBinding() instanceof IProblemBinding );
|
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
|
||||||
|
|
||||||
tu = parse( "void f() { typedef int x; int y; x * y; }", ParserLanguage.C ); //$NON-NLS-1$
|
tu = parse(
|
||||||
|
"void f() { typedef int x; int y; x * y; }", ParserLanguage.C); //$NON-NLS-1$
|
||||||
col = new CNameCollector();
|
col = new CNameCollector();
|
||||||
tu.accept( col );
|
tu.accept(col);
|
||||||
for( int i = 0; i < col.size(); ++i )
|
for (int i = 0; i < col.size(); ++i)
|
||||||
assertFalse( col.getName( i ).resolveBinding() instanceof IProblemBinding );
|
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug85786() throws Exception {
|
public void testBug85786() throws Exception {
|
||||||
IASTTranslationUnit tu = parse( "void f( int ); void foo () { void * p = &f; ( (void (*) (int)) p ) ( 1 ); }", ParserLanguage.C ); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(
|
||||||
|
"void f( int ); void foo () { void * p = &f; ( (void (*) (int)) p ) ( 1 ); }", ParserLanguage.C); //$NON-NLS-1$
|
||||||
CNameCollector nameResolver = new CNameCollector();
|
CNameCollector nameResolver = new CNameCollector();
|
||||||
tu.accept( nameResolver );
|
tu.accept(nameResolver);
|
||||||
assertNoProblemBindings( nameResolver );
|
assertNoProblemBindings(nameResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertNoProblemBindings(CNameCollector col) {
|
protected void assertNoProblemBindings(CNameCollector col) {
|
||||||
Iterator i = col.nameList.iterator();
|
Iterator i = col.nameList.iterator();
|
||||||
while( i.hasNext() )
|
while (i.hasNext()) {
|
||||||
{
|
|
||||||
IASTName n = (IASTName) i.next();
|
IASTName n = (IASTName) i.next();
|
||||||
assertFalse( n.resolveBinding() instanceof IProblemBinding );
|
assertFalse(n.resolveBinding() instanceof IProblemBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertProblemBindings(CNameCollector col, int count ) {
|
protected void assertProblemBindings(CNameCollector col, int count) {
|
||||||
Iterator i = col.nameList.iterator();
|
Iterator i = col.nameList.iterator();
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
while( i.hasNext() )
|
while (i.hasNext()) {
|
||||||
{
|
|
||||||
IASTName n = (IASTName) i.next();
|
IASTName n = (IASTName) i.next();
|
||||||
if( n.getBinding() instanceof IProblemBinding )
|
if (n.getBinding() instanceof IProblemBinding)
|
||||||
++sum;
|
++sum;
|
||||||
}
|
}
|
||||||
assertEquals( count, sum );
|
assertEquals(count, sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug94365() throws Exception {
|
public void testBug94365() throws Exception {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append( "#define ONE(a, ...) int x\n"); //$NON-NLS-1$
|
buffer.append("#define ONE(a, ...) int x\n"); //$NON-NLS-1$
|
||||||
buffer.append( "#define TWO(b, args...) int y\n"); //$NON-NLS-1$
|
buffer.append("#define TWO(b, args...) int y\n"); //$NON-NLS-1$
|
||||||
buffer.append( "int main()\n"); //$NON-NLS-1$
|
buffer.append("int main()\n"); //$NON-NLS-1$
|
||||||
buffer.append( "{\n"); //$NON-NLS-1$
|
buffer.append("{\n"); //$NON-NLS-1$
|
||||||
buffer.append( "ONE(\"string\"); /* err */\n"); //$NON-NLS-1$
|
buffer.append("ONE(\"string\"); /* err */\n"); //$NON-NLS-1$
|
||||||
buffer.append( "TWO(\"string\"); /* err */\n"); //$NON-NLS-1$
|
buffer.append("TWO(\"string\"); /* err */\n"); //$NON-NLS-1$
|
||||||
buffer.append( "return 0; \n"); //$NON-NLS-1$
|
buffer.append("return 0; \n"); //$NON-NLS-1$
|
||||||
buffer.append( "}\n"); //$NON-NLS-1$
|
buffer.append("}\n"); //$NON-NLS-1$
|
||||||
|
|
||||||
parse( buffer.toString(), ParserLanguage.C );
|
parse(buffer.toString(), ParserLanguage.C);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testBug95119() throws Exception {
|
public void testBug95119() throws Exception {
|
||||||
StringBuffer buff = new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
buff.append("#define MACRO(a)\n"); //$NON-NLS-1$
|
buff.append("#define MACRO(a)\n"); //$NON-NLS-1$
|
||||||
|
@ -3138,11 +3048,13 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
|
IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
|
||||||
IASTDeclaration[] declarations = tu.getDeclarations();
|
IASTDeclaration[] declarations = tu.getDeclarations();
|
||||||
assertEquals( declarations.length, 1 );
|
assertEquals(declarations.length, 1);
|
||||||
assertNotNull( declarations[0] );
|
assertNotNull(declarations[0]);
|
||||||
assertTrue( declarations[0] instanceof IASTFunctionDefinition );
|
assertTrue(declarations[0] instanceof IASTFunctionDefinition);
|
||||||
assertEquals( ((IASTFunctionDefinition)declarations[0]).getDeclarator().getName().toString(), "main");
|
assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator()
|
||||||
assertTrue( ((IASTCompoundStatement)((IASTFunctionDefinition)declarations[0]).getBody()).getStatements()[0] instanceof IASTNullStatement );
|
.getName().toString(), "main");
|
||||||
|
assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
|
||||||
|
.getBody()).getStatements()[0] instanceof IASTNullStatement);
|
||||||
|
|
||||||
buff = new StringBuffer();
|
buff = new StringBuffer();
|
||||||
buff.append("#define MACRO(a)\n"); //$NON-NLS-1$
|
buff.append("#define MACRO(a)\n"); //$NON-NLS-1$
|
||||||
|
@ -3152,11 +3064,19 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
|
|
||||||
tu = parse(buff.toString(), ParserLanguage.C);
|
tu = parse(buff.toString(), ParserLanguage.C);
|
||||||
declarations = tu.getDeclarations();
|
declarations = tu.getDeclarations();
|
||||||
assertEquals( declarations.length, 1 );
|
assertEquals(declarations.length, 1);
|
||||||
assertNotNull( declarations[0] );
|
assertNotNull(declarations[0]);
|
||||||
assertTrue( declarations[0] instanceof IASTFunctionDefinition );
|
assertTrue(declarations[0] instanceof IASTFunctionDefinition);
|
||||||
assertEquals( ((IASTFunctionDefinition)declarations[0]).getDeclarator().getName().toString(), "main");
|
assertEquals(((IASTFunctionDefinition) declarations[0]).getDeclarator()
|
||||||
assertTrue( ((IASTCompoundStatement)((IASTFunctionDefinition)declarations[0]).getBody()).getStatements()[0] instanceof IASTNullStatement );
|
.getName().toString(), "main");
|
||||||
|
assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
|
||||||
|
.getBody()).getStatements()[0] instanceof IASTNullStatement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug81739() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer("typedef long _TYPE;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("typedef _TYPE TYPE;\n"); //$NON-NLS-1$
|
||||||
|
buffer.append("int function(TYPE (* pfv)(int parm));\n"); //$NON-NLS-1$
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -868,16 +868,16 @@ public class QuickParser2Tests extends TestCase {
|
||||||
parse(code.toString(), false);
|
parse(code.toString(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug36247() throws Exception {
|
// public void testBug36247() throws Exception {
|
||||||
Writer code = new StringWriter();
|
// Writer code = new StringWriter();
|
||||||
code.write("class A {\n"); //$NON-NLS-1$
|
// code.write("class A {\n"); //$NON-NLS-1$
|
||||||
code.write("INLINE_DEF int f ();\n"); //$NON-NLS-1$
|
// code.write("INLINE_DEF int f ();\n"); //$NON-NLS-1$
|
||||||
code.write("INLINE_DEF A g ();"); //$NON-NLS-1$
|
// code.write("INLINE_DEF A g ();"); //$NON-NLS-1$
|
||||||
code.write("INLINE_DEF A * h ();"); //$NON-NLS-1$
|
// code.write("INLINE_DEF A * h ();"); //$NON-NLS-1$
|
||||||
code.write("INLINE_DEF A & unlock( void );"); //$NON-NLS-1$
|
// code.write("INLINE_DEF A & unlock( void );"); //$NON-NLS-1$
|
||||||
code.write("};"); //$NON-NLS-1$
|
// code.write("};"); //$NON-NLS-1$
|
||||||
parse(code.toString());
|
// parse(code.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void testStruct() throws Exception {
|
public void testStruct() throws Exception {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class BasicCompletionTest extends CompletionTestBase {
|
||||||
ASTCompletionNode node = getGPPCompletionNode(code.toString());
|
ASTCompletionNode node = getGPPCompletionNode(code.toString());
|
||||||
IASTName[] names = node.getNames();
|
IASTName[] names = node.getNames();
|
||||||
// There are three names, one as an expression, one that isn't connected, one as a declaration
|
// There are three names, one as an expression, one that isn't connected, one as a declaration
|
||||||
assertEquals(3, names.length);
|
assertEquals(4, names.length);
|
||||||
// The expression points to our functions
|
// The expression points to our functions
|
||||||
IBinding[] bindings = names[0].resolvePrefix();
|
IBinding[] bindings = names[0].resolvePrefix();
|
||||||
// There should be two since they both start with fu
|
// There should be two since they both start with fu
|
||||||
|
@ -79,9 +79,9 @@ public class BasicCompletionTest extends CompletionTestBase {
|
||||||
// C++
|
// C++
|
||||||
ASTCompletionNode node = getGPPCompletionNode(code.toString());
|
ASTCompletionNode node = getGPPCompletionNode(code.toString());
|
||||||
IASTName[] names = node.getNames();
|
IASTName[] names = node.getNames();
|
||||||
assertEquals(2, names.length);
|
assertEquals(3, names.length);
|
||||||
assertNull(names[0].getTranslationUnit());
|
assertNull(names[0].getTranslationUnit());
|
||||||
IBinding[] bindings = names[1].resolvePrefix();
|
IBinding[] bindings = names[2].resolvePrefix();
|
||||||
assertEquals(1, bindings.length);
|
assertEquals(1, bindings.length);
|
||||||
assertEquals("blah", ((ITypedef)bindings[0]).getName());
|
assertEquals("blah", ((ITypedef)bindings[0]).getName());
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFieldDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTForStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
|
@ -1037,18 +1038,83 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
return compoundStatement();
|
return compoundStatement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract IASTDeclarator initDeclarator() throws EndOfFileException,
|
||||||
|
BacktrackException;
|
||||||
/**
|
/**
|
||||||
* @param flags
|
* @param flags
|
||||||
* input flags that are used to make our decision
|
* input flags that are used to make our decision
|
||||||
* @return whether or not this looks like a a declarator follows
|
* @return whether or not this looks like a a declarator follows
|
||||||
|
* @throws
|
||||||
* @throws EndOfFileException
|
* @throws EndOfFileException
|
||||||
* we could encounter EOF while looking ahead
|
* we could encounter EOF while looking ahead
|
||||||
*/
|
*/
|
||||||
protected boolean lookAheadForDeclarator(Flags flags)
|
protected boolean lookAheadForDeclarator(Flags flags)
|
||||||
throws EndOfFileException {
|
{
|
||||||
return flags.haveEncounteredTypename()
|
if( flags.typeId ) return false;
|
||||||
&& ((LT(2) != IToken.tIDENTIFIER || (LT(3) != IToken.tLPAREN && LT(3) != IToken.tASSIGN)) && !LA(
|
IToken mark = null;
|
||||||
2).isPointer());
|
try
|
||||||
|
{
|
||||||
|
mark = mark();
|
||||||
|
}
|
||||||
|
catch( EndOfFileException eof )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IASTDeclarator d = initDeclarator();
|
||||||
|
IToken la = LA(1);
|
||||||
|
backup( mark );
|
||||||
|
if( la == null || la.getType() == IToken.tEOC )
|
||||||
|
return false;
|
||||||
|
final ASTNode n = ((ASTNode)d);
|
||||||
|
final int length = n.getLength();
|
||||||
|
final int offset = n.getOffset();
|
||||||
|
if( length == 0 )
|
||||||
|
return false;
|
||||||
|
if( flags.parm )
|
||||||
|
{
|
||||||
|
ASTNode name = (ASTNode)d.getName();
|
||||||
|
if( name.getOffset() == offset && name.getLength() == length )
|
||||||
|
return false;
|
||||||
|
if( d.getInitializer() != null )
|
||||||
|
{
|
||||||
|
ASTNode init = (ASTNode) d.getInitializer();
|
||||||
|
if( name.getOffset() == offset && n.getOffset() + n.getLength() == init.getOffset() + init.getLength() )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( la.getType() )
|
||||||
|
{
|
||||||
|
case IToken.tCOMMA:
|
||||||
|
case IToken.tRPAREN:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( la.getType() )
|
||||||
|
{
|
||||||
|
case IToken.tCOMMA:
|
||||||
|
case IToken.tLBRACE:
|
||||||
|
return true;
|
||||||
|
case IToken.tSEMI:
|
||||||
|
if( d instanceof IASTFieldDeclarator )
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( BacktrackException bte )
|
||||||
|
{
|
||||||
|
backup( mark );
|
||||||
|
return false;
|
||||||
|
} catch (EndOfFileException e) {
|
||||||
|
backup( mark );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Flags {
|
public static class Flags {
|
||||||
|
@ -1058,19 +1124,21 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
||||||
private boolean encounteredRawType = false;
|
private boolean encounteredRawType = false;
|
||||||
|
|
||||||
// have we encountered a raw type yet?
|
// have we encountered a raw type yet?
|
||||||
private final boolean parm;
|
boolean parm = false;
|
||||||
|
|
||||||
// is this for a simpleDeclaration or parameterDeclaration?
|
// is this for a simpleDeclaration or parameterDeclaration?
|
||||||
private final boolean constructor;
|
boolean constructor = false;
|
||||||
|
boolean typeId = false;
|
||||||
|
|
||||||
// are we attempting the constructor strategy?
|
// are we attempting the constructor strategy?
|
||||||
public Flags(boolean parm, boolean c) {
|
public Flags(boolean parm, boolean c, boolean t) {
|
||||||
this.parm = parm;
|
this.parm = parm;
|
||||||
constructor = c;
|
constructor = c;
|
||||||
|
typeId =t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Flags(boolean parm) {
|
public Flags(boolean parm, boolean typeId ) {
|
||||||
this(parm, false);
|
this(parm, false, typeId );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -442,7 +442,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
firstToken = null; // necessary for scalability
|
firstToken = null; // necessary for scalability
|
||||||
|
|
||||||
IASTDeclSpecifier declSpec = declSpecifierSeq(false);
|
IASTDeclSpecifier declSpec = declSpecifierSeq(false, false);
|
||||||
|
|
||||||
IASTDeclarator [] declarators = new IASTDeclarator[2];
|
IASTDeclarator [] declarators = new IASTDeclarator[2];
|
||||||
if (LT(1) != IToken.tSEMI) {
|
if (LT(1) != IToken.tSEMI) {
|
||||||
|
@ -1203,7 +1203,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
declSpecifier = declSpecifierSeq(false);
|
declSpecifier = declSpecifierSeq(false, true);
|
||||||
declarator = declarator();
|
declarator = declarator();
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
|
@ -1304,9 +1304,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CASTPointer();
|
return new CASTPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTDeclSpecifier declSpecifierSeq(boolean parm)
|
protected IASTDeclSpecifier declSpecifierSeq(boolean parm, boolean forTypeId)
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
Flags flags = new Flags(parm);
|
Flags flags = new Flags(parm,forTypeId);
|
||||||
|
|
||||||
int startingOffset = LA(1).getOffset();
|
int startingOffset = LA(1).getOffset();
|
||||||
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
int storageClass = IASTDeclSpecifier.sc_unspecified;
|
||||||
|
@ -1319,7 +1319,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTElaboratedTypeSpecifier elabSpec = null;
|
IASTElaboratedTypeSpecifier elabSpec = null;
|
||||||
IASTEnumerationSpecifier enumSpec = null;
|
IASTEnumerationSpecifier enumSpec = null;
|
||||||
IASTExpression typeofExpression = null;
|
IASTExpression typeofExpression = null;
|
||||||
boolean isTypedef = false;
|
|
||||||
IToken last = null;
|
IToken last = null;
|
||||||
|
|
||||||
declSpecifiers: for (;;) {
|
declSpecifiers: for (;;) {
|
||||||
|
@ -1342,7 +1341,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
last = consume();
|
last = consume();
|
||||||
break;
|
break;
|
||||||
case IToken.t_typedef:
|
case IToken.t_typedef:
|
||||||
isTypedef = true;
|
|
||||||
storageClass = IASTDeclSpecifier.sc_typedef;
|
storageClass = IASTDeclSpecifier.sc_typedef;
|
||||||
last = consume();
|
last = consume();
|
||||||
break;
|
break;
|
||||||
|
@ -1438,21 +1436,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (flags.haveEncounteredRawType()) {
|
if (flags.haveEncounteredRawType()) {
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
if (parm && flags.haveEncounteredTypename()) {
|
if (flags.haveEncounteredTypename()) {
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
if (lookAheadForDeclarator(flags)) {
|
if (lookAheadForDeclarator(flags)) {
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
}
|
}
|
||||||
switch (LT(2)) {
|
|
||||||
case IToken.tLPAREN:
|
|
||||||
if (isTypedef)
|
|
||||||
break;
|
|
||||||
case IToken.tSEMI:
|
|
||||||
case IToken.tASSIGN:
|
|
||||||
// TODO more
|
|
||||||
break declSpecifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
identifier = identifier();
|
identifier = identifier();
|
||||||
last = identifier;
|
last = identifier;
|
||||||
|
@ -1930,10 +1919,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (LA(1).getType() != IToken.tIDENTIFIER)
|
|
||||||
break;
|
|
||||||
|
|
||||||
} while (true);
|
} while (false);
|
||||||
|
|
||||||
IASTDeclarator d = null;
|
IASTDeclarator d = null;
|
||||||
if (numKnRCParms > 0) {
|
if (numKnRCParms > 0) {
|
||||||
|
@ -2165,7 +2152,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
IToken current = LA(1);
|
IToken current = LA(1);
|
||||||
int startingOffset = current.getOffset();
|
int startingOffset = current.getOffset();
|
||||||
IASTDeclSpecifier declSpec = declSpecifierSeq(true);
|
IASTDeclSpecifier declSpec = declSpecifierSeq(true, false);
|
||||||
|
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
if (LT(1) != IToken.tSEMI)
|
if (LT(1) != IToken.tSEMI)
|
||||||
|
|
|
@ -540,6 +540,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) {
|
if (LT(1) == IToken.tIDENTIFIER || LT(1) == IToken.tCOLONCOLON) {
|
||||||
try {
|
try {
|
||||||
nameDuple = name();
|
nameDuple = name();
|
||||||
|
if( nameDuple.length() == 1 )
|
||||||
|
{
|
||||||
|
backup(mark);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( nameDuple.getLastToken().getType() != IToken.tCOLONCOLON )
|
||||||
|
{
|
||||||
|
backup(mark);
|
||||||
|
return;
|
||||||
|
}
|
||||||
last = nameDuple.getLastToken();
|
last = nameDuple.getLastToken();
|
||||||
} catch (BacktrackException bt) {
|
} catch (BacktrackException bt) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
|
@ -931,7 +941,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
declSpecifier = declSpecifierSeq(true, true);
|
declSpecifier = declSpecifierSeq(true, true, true);
|
||||||
if (LT(1) != IToken.tEOC)
|
if (LT(1) != IToken.tEOC)
|
||||||
declarator = declarator(
|
declarator = declarator(
|
||||||
SimpleDeclarationStrategy.TRY_CONSTRUCTOR, forNewExpression);
|
SimpleDeclarationStrategy.TRY_CONSTRUCTOR, forNewExpression);
|
||||||
|
@ -2744,7 +2754,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
firstToken = null; // necessary for scalability
|
firstToken = null; // necessary for scalability
|
||||||
|
|
||||||
ICPPASTDeclSpecifier declSpec = declSpecifierSeq(false,
|
ICPPASTDeclSpecifier declSpec = declSpecifierSeq(false,
|
||||||
strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR);
|
strategy == SimpleDeclarationStrategy.TRY_CONSTRUCTOR, false);
|
||||||
IASTDeclarator[] declarators = new IASTDeclarator[2];
|
IASTDeclarator[] declarators = new IASTDeclarator[2];
|
||||||
if (LT(1) != IToken.tSEMI && LT(1) != IToken.tEOC) {
|
if (LT(1) != IToken.tSEMI && LT(1) != IToken.tEOC) {
|
||||||
declarators = (IASTDeclarator[]) ArrayUtil
|
declarators = (IASTDeclarator[]) ArrayUtil
|
||||||
|
@ -3008,7 +3018,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
protected ICPPASTParameterDeclaration parameterDeclaration()
|
protected ICPPASTParameterDeclaration parameterDeclaration()
|
||||||
throws BacktrackException, EndOfFileException {
|
throws BacktrackException, EndOfFileException {
|
||||||
IToken current = LA(1);
|
IToken current = LA(1);
|
||||||
IASTDeclSpecifier declSpec = declSpecifierSeq(true, false);
|
IASTDeclSpecifier declSpec = declSpecifierSeq(true, false, false);
|
||||||
IASTDeclarator declarator = null;
|
IASTDeclarator declarator = null;
|
||||||
if (LT(1) != IToken.tSEMI)
|
if (LT(1) != IToken.tSEMI)
|
||||||
declarator = initDeclarator(SimpleDeclarationStrategy.TRY_FUNCTION);
|
declarator = initDeclarator(SimpleDeclarationStrategy.TRY_FUNCTION);
|
||||||
|
@ -3126,21 +3136,22 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
* enumSpecifier Notes: - folded in storageClassSpecifier, typeSpecifier,
|
* enumSpecifier Notes: - folded in storageClassSpecifier, typeSpecifier,
|
||||||
* functionSpecifier - folded elaboratedTypeSpecifier into classSpecifier
|
* functionSpecifier - folded elaboratedTypeSpecifier into classSpecifier
|
||||||
* and enumSpecifier - find template names in name
|
* and enumSpecifier - find template names in name
|
||||||
*
|
|
||||||
* @param parm
|
* @param parm
|
||||||
* Is this for a parameter declaration (true) or simple
|
* Is this for a parameter declaration (true) or simple
|
||||||
* declaration (false)
|
* declaration (false)
|
||||||
* @param tryConstructor
|
* @param tryConstructor
|
||||||
* true for constructor, false for pointer to function strategy
|
* true for constructor, false for pointer to function strategy
|
||||||
|
* @param forTypeId TODO
|
||||||
|
*
|
||||||
* @return TODO
|
* @return TODO
|
||||||
* @throws BacktrackException
|
* @throws BacktrackException
|
||||||
* request a backtrack
|
* request a backtrack
|
||||||
*/
|
*/
|
||||||
protected ICPPASTDeclSpecifier declSpecifierSeq(boolean parm,
|
protected ICPPASTDeclSpecifier declSpecifierSeq(boolean parm,
|
||||||
boolean tryConstructor) throws BacktrackException,
|
boolean tryConstructor, boolean forTypeId) throws BacktrackException,
|
||||||
EndOfFileException {
|
EndOfFileException {
|
||||||
IToken firstToken = LA(1);
|
IToken firstToken = LA(1);
|
||||||
Flags flags = new Flags(parm, tryConstructor);
|
Flags flags = new Flags(parm, tryConstructor, forTypeId );
|
||||||
IToken last = null;
|
IToken last = null;
|
||||||
|
|
||||||
boolean isInline = false, isVirtual = false, isExplicit = false, isFriend = false;
|
boolean isInline = false, isVirtual = false, isExplicit = false, isFriend = false;
|
||||||
|
@ -3306,7 +3317,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (flags.haveEncounteredRawType())
|
if (flags.haveEncounteredRawType())
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
|
|
||||||
if (parm && flags.haveEncounteredTypename())
|
if (flags.haveEncounteredTypename())
|
||||||
break declSpecifiers;
|
break declSpecifiers;
|
||||||
|
|
||||||
if (lookAheadForConstructorOrOperator(flags))
|
if (lookAheadForConstructorOrOperator(flags))
|
||||||
|
@ -3532,6 +3543,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
return new CPPASTElaboratedTypeSpecifier();
|
return new CPPASTElaboratedTypeSpecifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IASTDeclarator initDeclarator() throws EndOfFileException, BacktrackException {
|
||||||
|
return initDeclarator( SimpleDeclarationStrategy.TRY_FUNCTION );
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Parses the initDeclarator construct of the ANSI C++ spec. initDeclarator :
|
* Parses the initDeclarator construct of the ANSI C++ spec. initDeclarator :
|
||||||
* declarator ("=" initializerClause | "(" expressionList ")")?
|
* declarator ("=" initializerClause | "(" expressionList ")")?
|
||||||
|
@ -3920,10 +3934,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (LA(1).getType() != IToken.tIDENTIFIER)
|
|
||||||
break;
|
|
||||||
|
|
||||||
} while (true);
|
} while (false);
|
||||||
|
|
||||||
IASTDeclarator d = null;
|
IASTDeclarator d = null;
|
||||||
if (isFunction) {
|
if (isFunction) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue