1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Corrections to existing test-cases + additional ones.

This commit is contained in:
Markus Schorn 2008-06-12 13:19:19 +00:00
parent cd4a0fef03
commit b6703ee592
13 changed files with 300 additions and 97 deletions

View file

@ -28,12 +28,14 @@ import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTConditionalExpression;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
@ -541,4 +543,24 @@ public class AST2BaseTest extends BaseTestCase {
}
assertEquals(count, sum);
}
final protected IASTFunctionDefinition getFunctionDefinition(IASTTranslationUnit tu, int i_decl) {
IASTDeclaration[] decls= tu.getDeclarations();
assertTrue(decls.length > i_decl);
assertInstance(decls[i_decl], IASTFunctionDefinition.class);
return (IASTFunctionDefinition) decls[i_decl];
}
final protected IASTStatement getStatement(IASTFunctionDefinition fdef, int i_stmt) {
IASTCompoundStatement compound= (IASTCompoundStatement) fdef.getBody();
IASTStatement[] stmts= compound.getStatements();
assertTrue(stmts.length > i_stmt);
return stmts[i_stmt];
}
final protected IASTExpression getExpressionOfStatement(IASTFunctionDefinition fdef, int i) {
IASTStatement stmt= getStatement(fdef, i);
assertInstance(stmt, IASTExpressionStatement.class);
return ((IASTExpressionStatement) stmt).getExpression();
}
}

View file

@ -14,10 +14,15 @@ package org.eclipse.cdt.core.parser.tests.ast2;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/**
* @author dsteffle
@ -628,21 +633,25 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
}
// #define N sizeof(T)
// void test() {
// char buf[N];
// T obj; // obj initialized to its original value
// memcpy(buf, &obj, N); // between these two calls to memcpy,
// // obj might be modified
// memcpy(&obj, buf, N); // at this point, each subobject of obj of scalar type
// // holds its original value
// }
public void test3_9s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
// void test() {
// T* t1p;
// T* t2p;
// // provided that t2p points to an initialized object ...
// memcpy(t1p, t2p, sizeof(T)); // at this point, every subobject of POD type in *t1p contains
// // the same value as the corresponding subobject in *t2p
// }
public void test3_9s3() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
@ -762,6 +771,73 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
}
// void test() {
// new (int (*[10])());
// };
public void test5_3_4s3() throws Exception {
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
IASTFunctionDefinition fdef= getFunctionDefinition(tu, 0);
IASTExpression expr= getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
assertEquals(0, newExpr.getNewTypeIdArrayExpressions().length);
IASTTypeId typeid= newExpr.getTypeId();
isTypeEqual(CPPVisitor.createType(typeid), "int () * []");
}
// typedef int T;
// void test(int f) {
// new T;
// new(2,f) T;
// new T[5];
// new (2,f) T[5];
// };
public void _test5_3_4s12() throws Exception {
// failing see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
IASTTranslationUnit tu= parse(getAboveComment(), ParserLanguage.CPP, true, 0);
IASTFunctionDefinition fdef= getFunctionDefinition(tu, 1);
// new T;
IASTExpression expr= getExpressionOfStatement(fdef, 0);
assertInstance(expr, ICPPASTNewExpression.class);
ICPPASTNewExpression newExpr= (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
assertEquals(0, newExpr.getNewTypeIdArrayExpressions().length);
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new(2,f) T;
expr= getExpressionOfStatement(fdef, 1);
assertInstance(expr, ICPPASTNewExpression.class);
newExpr= (ICPPASTNewExpression) expr;
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
assertNull(newExpr.getNewInitializer());
assertEquals(0, newExpr.getNewTypeIdArrayExpressions().length);
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int");
// new T[5];
expr= getExpressionOfStatement(fdef, 2);
assertInstance(expr, ICPPASTNewExpression.class);
newExpr= (ICPPASTNewExpression) expr;
assertNull(newExpr.getNewPlacement());
assertNull(newExpr.getNewInitializer());
assertEquals(1, newExpr.getNewTypeIdArrayExpressions().length);
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []");
// new (2,f) T[5];
expr= getExpressionOfStatement(fdef, 3);
assertInstance(expr, ICPPASTNewExpression.class);
newExpr= (ICPPASTNewExpression) expr;
assertInstance(newExpr.getNewPlacement(), IASTExpressionList.class);
assertNull(newExpr.getNewInitializer());
assertEquals(1, newExpr.getNewTypeIdArrayExpressions().length);
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), "int []");
}
// int n=2;
// int x=new float[n][5];
// int y=new float[5][n];
@ -1703,8 +1779,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// class C { };
// void h(int *(C[10])); // void h(int *(*_fp)(C _parm[10]));
// // not: void h(int *C[10]);
public void test8_2s7b() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
public void _test8_2s7b() throws Exception {
final String code = getAboveComment();
parse(code, ParserLanguage.CPP, true, 0);
BindingAssertionHelper ba= new BindingAssertionHelper(code, true);
IFunction f= ba.assertNonProblem("h", 1, IFunction.class);
isTypeEqual(f.getType(), "void (int * (C *) *)");
}
// namespace A {
@ -2192,8 +2272,10 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
// X a1;
// Y a2;
// int a3;
// void test() {
// a1 = a2; // error: Y assigned to X
// a1 = a3; // error: int assigned to X
// }
// int f(X);
// int f(Y);
// struct S { int a; };
@ -4383,10 +4465,12 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}
// void test() {
// Array<int> v1(20);
// Array<dcomplex> v2(30);
// v1[3] = 7; // Array<int>::operator[]()
// v2[3] = dcomplex(7,8); // Array<dcomplex>::operator[]()
// }
public void test14_5_1_1s2() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, false, 0);
}

View file

@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
@ -77,6 +78,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
@ -1061,7 +1063,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void f( Int i );
// void g( char * );
// void g( char [] );
// void h( int()() );
// void h( int(a)() );
// void h( int (*) () );
public void testFunctionDeclarations() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@ -1069,8 +1071,11 @@ public class AST2CPPTests extends AST2BaseTest {
tu.accept(collector);
IFunction f = (IFunction) collector.getName(1).resolveBinding();
isTypeEqual(f.getType(), "void (int)");
IFunction g = (IFunction) collector.getName(8).resolveBinding();
isTypeEqual(g.getType(), "void (char *)");
IFunction h = (IFunction) collector.getName(12).resolveBinding();
isTypeEqual(h.getType(), "void (int () *)");
assertInstances(collector, f, 3);
assertInstances(collector, g, 2);
@ -5640,4 +5645,95 @@ public class AST2CPPTests extends AST2BaseTest {
public void _testBug235196() throws Exception {
parseAndCheckBindings(getAboveComment());
}
// typedef int tint;
// class X {
// typedef int xtint;
// X();
// ~X();
// operator int ();
// tint(a); // 1
// };
// X::X() {}
// X::~X() {}
// X::operator int() {}
// X::xtint(a); // 2
public void _testEmptyDeclSpecifier() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("X {", 1, ICPPClassType.class);
ba.assertNonProblem("X()", 1, ICPPConstructor.class);
ba.assertNonProblem("~X", 2, ICPPMethod.class);
ba.assertNonProblem("operator int", 12, ICPPMethod.class);
ba.assertNonProblem("a); // 1", 1, ICPPField.class);
ba.assertNonProblem("X() {}", 1, ICPPConstructor.class);
ba.assertNonProblem("~X() {}", 2, ICPPMethod.class);
ba.assertNonProblem("operator int() {}", 12, ICPPMethod.class);
ba.assertNonProblem("a); // 2", 1, ICPPVariable.class);
}
// void* operator new (unsigned int, int[100]);
// typedef int T;
// int p[100];
// void test(int f) {
// new T;
// new T(f);
// new (p) T;
// new (p) T(f);
// new (T);
// new (T)(f);
// new (p) (T);
// new (p) (T)(f);
// new T[f][f];
// new T[f][f](f);
// new (p) T[f][f];
// new (p) T[f][f](f);
// new (T[f][f]);
// new (T[f][f])(f);
// new (p) (T[f][f]);
// new (p) (T[f][f])(f);
// };
public void _testNewPlacement_Bug236856() throws Exception {
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fdef= getFunctionDefinition(tu, 3);
checkNewExpression(fdef, 0, null, "int", 0, null);
checkNewExpression(fdef, 1, null, "int", 0, IASTIdExpression.class);
checkNewExpression(fdef, 2, IASTIdExpression.class, "int", 0, null);
checkNewExpression(fdef, 3, IASTIdExpression.class, "int", 0, IASTIdExpression.class);
checkNewExpression(fdef, 4, null, "int", 0, null);
checkNewExpression(fdef, 5, null, "int", 0, IASTIdExpression.class);
checkNewExpression(fdef, 6, IASTIdExpression.class, "int", 0, null);
checkNewExpression(fdef, 7, IASTIdExpression.class, "int", 0, IASTIdExpression.class);
checkNewExpression(fdef, 8, null, "int [] []", 2, null);
checkNewExpression(fdef, 9, null, "int [] []", 2, IASTIdExpression.class);
checkNewExpression(fdef, 10, IASTIdExpression.class, "int [] []", 2, null);
checkNewExpression(fdef, 11, IASTIdExpression.class, "int [] []", 2, IASTIdExpression.class);
checkNewExpression(fdef, 12, null, "int [] []", 2, null);
checkNewExpression(fdef, 13, null, "int [] []", 2, IASTIdExpression.class);
checkNewExpression(fdef, 14, IASTIdExpression.class, "int [] []", 2, null);
checkNewExpression(fdef, 15, IASTIdExpression.class, "int [] []", 2, IASTIdExpression.class);
}
private void checkNewExpression(IASTFunctionDefinition fdef, int i_expr, Class<?> placement, String type, int array, Class<?> init) {
IASTExpression expr;
ICPPASTNewExpression newExpr;
expr= getExpressionOfStatement(fdef, i_expr);
assertInstance(expr, ICPPASTNewExpression.class);
newExpr= (ICPPASTNewExpression) expr;
if (placement == null) {
assertNull(newExpr.getNewPlacement());
} else {
assertInstance(newExpr.getNewPlacement(), placement);
}
if (init == null) {
assertNull(newExpr.getNewInitializer());
} else {
assertInstance(newExpr.getNewInitializer(), init);
}
assertEquals(array, newExpr.getNewTypeIdArrayExpressions().length);
isTypeEqual(CPPVisitor.createType(newExpr.getTypeId()), type);
}
}

View file

@ -171,10 +171,12 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
public void test5_1_2_3s15() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("//#include <stdio.h>\n"); //$NON-NLS-1$
buffer.append("int f() {");
buffer.append("int sum;\n"); //$NON-NLS-1$
buffer.append("char *p;\n"); //$NON-NLS-1$
buffer.append("sum = sum * 10 - '0' + (*p++ = getchar());\n"); //$NON-NLS-1$
buffer.append("sum = (((sum * 10) - '0') + ((*(p++)) = (getchar())));\n"); //$NON-NLS-1$
buffer.append("}\n"); //$NON-NLS-1$
parseCandCPP(buffer.toString(), false, 0);
}
@ -656,6 +658,9 @@ public class AST2CSpecTest extends AST2SpecBaseTest {
*/
public void test6_7_2_1s17() throws Exception {
StringBuffer buffer = new StringBuffer();
// offsetoff is a macro defined in stddef.h, using GNU definition
buffer.append("#define offsetof(TYPE, MEMBER) ((size_t) (&((TYPE *)0)->MEMBER))\n");
buffer.append("struct s { int n; double d[]; };\n"); //$NON-NLS-1$
buffer.append("struct ss { int n; double d[1]; };\n"); //$NON-NLS-1$
buffer.append("int f() {\n"); //$NON-NLS-1$

View file

@ -4845,7 +4845,7 @@ public class AST2Tests extends AST2BaseTest {
// class C { };
// void f1(int(C)) { }
public void _testParamWithFunctionTypeCpp_Bug84242() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), false);
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
isTypeEqual(f.getType(), "void (int (C) *)");

View file

@ -854,9 +854,9 @@ public class CompleteParser2Tests extends BaseTestCase {
assertInstances( col, A, 2 );
}
public void testNewExpressions() throws Exception
{
IASTTranslationUnit tu = parse( "typedef int A; int B; int C; int D; int P; int*p = new (P) (A)[B][C][D];" ); //$NON-NLS-1$
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
public void _testNewExpressions() throws Exception {
IASTTranslationUnit tu = parse( "typedef int A; int B; int C; int D; int P; int*p = new (P) (A[B][C][D]);" ); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
tu.accept( col );

View file

@ -560,7 +560,6 @@ public class DOMLocationTests extends AST2BaseTest {
public void testBug86698_2() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append( "void foo() {\n"); //$NON-NLS-1$
buffer.append( "int f(int);\n"); //$NON-NLS-1$
buffer.append( "class C {\n"); //$NON-NLS-1$
buffer.append( "int i;\n"); //$NON-NLS-1$
@ -574,10 +573,10 @@ public class DOMLocationTests extends AST2BaseTest {
buffer.append( "{\n }\n"); //$NON-NLS-1$
buffer.append( "catch (...)\n"); //$NON-NLS-1$
buffer.append( "{\n }\n"); //$NON-NLS-1$
buffer.append( "}\n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
ICPPASTFunctionTryBlockDeclarator funC = (ICPPASTFunctionTryBlockDeclarator)((IASTFunctionDefinition)((IASTDeclarationStatement)((IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody()).getStatements()[2]).getDeclaration()).getDeclarator();
final IASTFunctionDefinition fdef = (IASTFunctionDefinition)tu.getDeclarations()[2];
ICPPASTFunctionTryBlockDeclarator funC = (ICPPASTFunctionTryBlockDeclarator)fdef.getDeclarator();
assertSoleLocation( funC, buffer.toString().indexOf("C::C(int ii, double id)\ntry\n: i(f(ii)), d(id)"), "C::C(int ii, double id)\ntry\n: i(f(ii)), d(id)".length() ); //$NON-NLS-1$//$NON-NLS-2$
}

View file

@ -43,7 +43,6 @@ public class DOMParserTestSuite extends TestCase {
suite.addTest(AST2CPPSpecTest.suite());
suite.addTest(AST2CPPSpecFailingTest.suite());
suite.addTestSuite(AST2CSpecTest.class);
suite.addTestSuite(AST2CSpecFailingTest.class);
suite.addTestSuite(DOMSelectionParseTest.class);
suite.addTestSuite(GCCCompleteParseExtensionsTest.class);
suite.addTestSuite(DOMPreprocessorInformationTest.class);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation and others.
* Copyright (c) 2002, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -1599,7 +1599,6 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
public void testBug86698B() throws Exception {
Writer writer = new StringWriter();
writer.write("void foo() {\n"); //$NON-NLS-1$
writer.write("int f(int);\n"); //$NON-NLS-1$
writer.write("class C {\n"); //$NON-NLS-1$
writer.write("int i;\n"); //$NON-NLS-1$
@ -1618,7 +1617,6 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
writer.write("// handles exceptions thrown from the ctorinitializer\n"); //$NON-NLS-1$
writer.write("// and from the constructor function body\n"); //$NON-NLS-1$
writer.write("}\n"); //$NON-NLS-1$
writer.write("}\n"); //$NON-NLS-1$
String code = writer.toString();
@ -1631,7 +1629,7 @@ public class DOMSelectionParseTest extends DOMSelectionParseBaseTest {
IName[] decls = getDeclarationOffTU((IASTName)node);
assertEquals(decls.length, 1);
assertEquals( decls[0].toString(), "i" ); //$NON-NLS-1$
assertEquals( ((ASTNode)decls[0]).getOffset(), 39);
assertEquals( code.indexOf("int i") + 4, ((ASTNode)decls[0]).getOffset());
assertEquals( ((ASTNode)decls[0]).getLength(), 1);
}

View file

@ -234,7 +234,8 @@ public class QuickParser2Tests extends TestCase {
parse("template <class A,B> X<A,C>::operator A&() { }; \n");
}
public void testBug36932C() throws Exception {
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
public void _testBug36932C() throws Exception {
parse("X::X( ) : var( new int ) {}");
parse("X::X( ) : var( new int(5) ) {}");
parse("X::X( ) : var( new int(B) ) {}");
@ -257,19 +258,19 @@ public class QuickParser2Tests extends TestCase {
parse("X::X( ) : var( new (int)(5) ) {}");
parse("X::X( ) : var( new (int)(B) ) {}");
parse("X::X( ) : var( new (int)(B,C) ) {}");
parse("X::X( ) : var( new (int)[5] ) {}");
parse("X::X( ) : var( new (int)[5][10] ) {}");
parse("X::X( ) : var( new (int)[B] ) {}");
parse("X::X( ) : var( new (int)[B][C][D] ) {}");
parse("X::X( ) : var( new (int[5]) ) {}");
parse("X::X( ) : var( new (int[5][10]) ) {}");
parse("X::X( ) : var( new (int[B]) ) {}");
parse("X::X( ) : var( new (int[B][C][D]) ) {}");
parse("X::X( ) : var( new (A) ) {}");
parse("X::X( ) : var( new (A)(5) ) {}");
parse("X::X( ) : var( new (A)(B) ) {}");
parse("X::X( ) : var( new (A)(B,C) ) {}");
parse("X::X( ) : var( new (A)[5] ) {}");
parse("X::X( ) : var( new (A)[5][10] ) {}");
parse("X::X( ) : var( new (A)[B] ) {}");
parse("X::X( ) : var( new (A)[B][C][D] ) {}");
parse("X::X( ) : var( new (A[5]) ) {}");
parse("X::X( ) : var( new (A[5][10]) ) {}");
parse("X::X( ) : var( new (A[B]) ) {}");
parse("X::X( ) : var( new (A[B][C][D]) ) {}");
parse("X::X( ) : var( new (0) int ) {}");
parse("X::X( ) : var( new (0) int(5) ) {}");
@ -293,19 +294,19 @@ public class QuickParser2Tests extends TestCase {
parse("X::X( ) : var( new (0) (int)(5) ) {}");
parse("X::X( ) : var( new (0) (int)(B) ) {}");
parse("X::X( ) : var( new (0) (int)(B,C) ) {}");
parse("X::X( ) : var( new (0) (int)[5] ) {}");
parse("X::X( ) : var( new (0) (int)[5][10] ) {}");
parse("X::X( ) : var( new (0) (int)[B] ) {}");
parse("X::X( ) : var( new (0) (int)[B][C][D] ) {}");
parse("X::X( ) : var( new (0) (int[5]) ) {}");
parse("X::X( ) : var( new (0) (int[5][10]) ) {}");
parse("X::X( ) : var( new (0) (int[B]) ) {}");
parse("X::X( ) : var( new (0) (int[B][C][D]) ) {}");
parse("X::X( ) : var( new (0) (A) ) {}");
parse("X::X( ) : var( new (0) (A)(5) ) {}");
parse("X::X( ) : var( new (0) (A)(B) ) {}");
parse("X::X( ) : var( new (0) (A)(B,C) ) {}");
parse("X::X( ) : var( new (0) (A)[5] ) {}");
parse("X::X( ) : var( new (0) (A)[5][10] ) {}");
parse("X::X( ) : var( new (0) (A)[B] ) {}");
parse("X::X( ) : var( new (0) (A)[B][C][D] ) {}");
parse("X::X( ) : var( new (0) (A[5]) ) {}");
parse("X::X( ) : var( new (0) (A[5][10]) ) {}");
parse("X::X( ) : var( new (0) (A[B]) ) {}");
parse("X::X( ) : var( new (0) (A[B][C][D]) ) {}");
parse("X::X( ) : var( new (P) int ) {}");
parse("X::X( ) : var( new (P) int(5) ) {}");
@ -329,19 +330,19 @@ public class QuickParser2Tests extends TestCase {
parse("X::X( ) : var( new (P) (int)(5) ) {}");
parse("X::X( ) : var( new (P) (int)(B) ) {}");
parse("X::X( ) : var( new (P) (int)(B,C) ) {}");
parse("X::X( ) : var( new (P) (int)[5] ) {}");
parse("X::X( ) : var( new (P) (int)[5][10] ) {}");
parse("X::X( ) : var( new (P) (int)[B] ) {}");
parse("X::X( ) : var( new (P) (int)[B][C][D] ) {}");
parse("X::X( ) : var( new (P) (int[5]) ) {}");
parse("X::X( ) : var( new (P) (int[5][10]) ) {}");
parse("X::X( ) : var( new (P) (int[B]) ) {}");
parse("X::X( ) : var( new (P) (int[B][C][D]) ) {}");
parse("X::X( ) : var( new (P) (A) ) {}");
parse("X::X( ) : var( new (P) (A)(5) ) {}");
parse("X::X( ) : var( new (P) (A)(B) ) {}");
parse("X::X( ) : var( new (P) (A)(B,C) ) {}");
parse("X::X( ) : var( new (P) (A)[5] ) {}");
parse("X::X( ) : var( new (P) (A)[5][10] ) {}");
parse("X::X( ) : var( new (P) (A)[B] ) {}");
parse("X::X( ) : var( new (P) (A)[B][C][D] ) {}");
parse("X::X( ) : var( new (P) (A[5]) ) {}");
parse("X::X( ) : var( new (P) (A[5][10]) ) {}");
parse("X::X( ) : var( new (P) (A[B]) ) {}");
parse("X::X( ) : var( new (P) (A[B][C][D]) ) {}");
}
public void testBugSingleton192() throws Exception {
@ -407,7 +408,8 @@ public class QuickParser2Tests extends TestCase {
parse("A::A( ) : var( new char [ (unsigned)bufSize ] ) {}");
}
public void testBug36932B() throws Exception {
// failing, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856
public void _testBug36932B() throws Exception {
parse(" p = new int; ");
parse(" p = new int(5); ");
parse(" p = new int(B); ");
@ -430,19 +432,19 @@ public class QuickParser2Tests extends TestCase {
parse(" p = new (int)(5); ");
parse(" p = new (int)(B); ");
parse(" p = new (int)(B,C); ");
parse(" p = new (int)[5]; ");
parse(" p = new (int)[5][10]; ");
parse(" p = new (int)[B]; ");
parse(" p = new (int)[B][C][D]; ");
parse(" p = new (int[5]); ");
parse(" p = new (int[5][10]); ");
parse(" p = new (int[B]); ");
parse(" p = new (int[B][C][D]); ");
parse(" p = new (A); ");
parse(" p = new (A)(5); ");
parse(" p = new (A)(B); ");
parse(" p = new (A)(B,C); ");
parse(" p = new (A)[5]; ");
parse(" p = new (A)[5][10]; ");
parse(" p = new (A)[B]; ");
parse(" p = new (A)[B][C][D]; ");
parse(" p = new (A[5]); ");
parse(" p = new (A[5][10]); ");
parse(" p = new (A[B]); ");
parse(" p = new (A[B][C][D]); ");
parse(" p = new (0) int; ");
parse(" p = new (0) int(5); ");
@ -466,19 +468,19 @@ public class QuickParser2Tests extends TestCase {
parse(" p = new (0) (int)(5); ");
parse(" p = new (0) (int)(B); ");
parse(" p = new (0) (int)(B,C); ");
parse(" p = new (0) (int)[5]; ");
parse(" p = new (0) (int)[5][10]; ");
parse(" p = new (0) (int)[B]; ");
parse(" p = new (0) (int)[B][C][D]; ");
parse(" p = new (0) (int[5]); ");
parse(" p = new (0) (int[5][10]); ");
parse(" p = new (0) (int[B]); ");
parse(" p = new (0) (int[B][C][D]); ");
parse(" p = new (0) (A); ");
parse(" p = new (0) (A)(5); ");
parse(" p = new (0) (A)(B); ");
parse(" p = new (0) (A)(B,C); ");
parse(" p = new (0) (A)[5]; ");
parse(" p = new (0) (A)[5][10]; ");
parse(" p = new (0) (A)[B]; ");
parse(" p = new (0) (A)[B][C][D]; ");
parse(" p = new (0) (A[5]); ");
parse(" p = new (0) (A[5][10]); ");
parse(" p = new (0) (A[B]); ");
parse(" p = new (0) (A[B][C][D]); ");
parse(" p = new (P) int; ");
parse(" p = new (P) int(5); ");
@ -502,19 +504,19 @@ public class QuickParser2Tests extends TestCase {
parse(" p = new (P) (int)(5); ");
parse(" p = new (P) (int)(B); ");
parse(" p = new (P) (int)(B,C); ");
parse(" p = new (P) (int)[5]; ");
parse(" p = new (P) (int)[5][10]; ");
parse(" p = new (P) (int)[B]; ");
parse(" p = new (P) (int)[B][C][D]; ");
parse(" p = new (P) (int[5]); ");
parse(" p = new (P) (int[5][10]); ");
parse(" p = new (P) (int[B]); ");
parse(" p = new (P) (int[B][C][D]); ");
parse(" p = new (P) (A); ");
parse(" p = new (P) (A)(5); ");
parse(" p = new (P) (A)(B); ");
parse(" p = new (P) (A)(B,C); ");
parse(" p = new (P) (A)[5]; ");
parse(" p = new (P) (A)[5][10]; ");
parse(" p = new (P) (A)[B]; ");
parse(" p = new (P) (A)[B][C][D]; ");
parse(" p = new (P) (A[5]); ");
parse(" p = new (P) (A[5][10]); ");
parse(" p = new (P) (A[B]); ");
parse(" p = new (P) (A[B][C][D]); ");
}
public void testBug36769A() throws Exception {

View file

@ -46,32 +46,34 @@ public class BasicCompletionTest extends CompletionTestBase {
// C++
IASTCompletionNode node = getGPPCompletionNode(code);
IASTName[] names = node.getNames();
// There are three names, one as an expression, one that isn't connected, one as a declaration
assertEquals(3, names.length);
// There are two names, one as an expression, one that isn't connected, one as a declaration
assertTrue(names.length > 1);
// The expression points to our functions
IBinding[] bindings = names[0].getCompletionContext().findBindings(names[0], true);
// There should be two since they both start with fu
assertEquals(2, bindings.length);
assertEquals("func", ((IFunction)bindings[0]).getName());
assertEquals("func2", ((IFunction)bindings[1]).getName());
// The second name shouldn't be hooked up
assertNull(names[1].getTranslationUnit());
// The third name shouldn't be hooked up either
assertNull(names[2].getTranslationUnit());
// The other names shouldn't be hooked up
for (int i = 1; i < names.length; i++) {
assertNull(names[i].getTranslationUnit());
}
// C
node = getGCCCompletionNode(code);
names = node.getNames();
// There are two names, one as an expression, one as a declaration
assertEquals(2, names.length);
assertTrue(names.length > 1);
// The expression points to our functions
bindings = sortBindings(names[0].getCompletionContext().findBindings(names[0], true));
// There should be two since they both start with fu
assertEquals(2, bindings.length);
assertEquals("func", ((IFunction)bindings[0]).getName());
assertEquals("func2", ((IFunction)bindings[1]).getName());
// The second name shouldn't be hooked up
assertNull(names[1].getTranslationUnit());
// The other names shouldn't be hooked up
for (int i = 1; i < names.length; i++) {
assertNull(names[i].getTranslationUnit());
}
}
public void testTypedef() throws Exception {

View file

@ -1007,9 +1007,9 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
// const int const_int = 0;
//
// f_int(i); // ok
// f_int(const int); // ok (passed as value)
// f_int(const_int); // ok (passed as value)
// f_const_int(i); // ok
// f_const_int(const int); // ok
// f_const_int(const_int); // ok
// }
//
// void f_const_int(const int const_int) {
@ -1017,9 +1017,9 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
// }
public void testConstIntParameter() {
getBindingFromASTName("f_int(i)", 5);
getBindingFromASTName("f_int(const int)", 5);
getBindingFromASTName("f_int(const_int)", 5);
getBindingFromASTName("f_const_int(i)", 11);
getBindingFromASTName("f_const_int(const int)", 11);
getBindingFromASTName("f_const_int(const_int)", 11);
getProblemFromASTName("f_int_ptr(&const_int)", 9);
}
@ -1385,8 +1385,8 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
Set expectedEnumerators = new HashSet();
expectedEnumerators.addAll(Arrays.asList(enumerators));
Set actualEnumerators = new HashSet();
for(int i=0; i<aEnumerators.length; i++){
actualEnumerators.add(aEnumerators[i].getName());
for (IEnumerator enumerator : aEnumerators) {
actualEnumerators.add(enumerator.getName());
}
assertEquals(expectedEnumerators, actualEnumerators);
}

View file

@ -62,24 +62,20 @@ int vol() volatile;
//!ICPPASTFunctionTryBlockDeclarator
//%CPP
void foo()
int f(int);
class C
{
int f(int);
class C
{
int i;
double d;
public:
C(int, double);
};
C::C(int ii, double id)
try
:i(f(ii)), d(id)
{
}
catch(...){
}
int i;
double d;
public:
C(int, double);
};
C::C(int ii, double id)
try
:i(f(ii)), d(id)
{
}
catch(...){
}