1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-04-18 12:39:03 -07:00
parent 103f577926
commit bbc8a48c8c
2 changed files with 81 additions and 83 deletions

View file

@ -1265,6 +1265,29 @@ public class AST2CPPTests extends AST2TestBase {
assertInstances(collector, x2, 1); assertInstances(collector, x2, 1);
} }
// class A { A(void); A(const A &); };
public void testConstructors() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP);
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding();
ICPPConstructor[] ctors = A.getConstructors();
assertNotNull(ctors);
assertEquals(ctors.length, 2);
assertEquals(0, ctors[0].getParameters().length);
assertEquals(1, ctors[1].getParameters().length);
IType t = ctors[1].getParameters()[0].getType();
assertTrue(t instanceof ICPPReferenceType);
assertTrue(((ICPPReferenceType) t).getType() instanceof IQualifierType);
IQualifierType qt = (IQualifierType) ((ICPPReferenceType) t).getType();
assertTrue(qt.isConst());
assertSame(qt.getType(), A);
}
// class A {}; // class A {};
public void testImplicitConstructors() throws Exception { public void testImplicitConstructors() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTTranslationUnit tu = parse(getAboveComment(), CPP);
@ -1289,27 +1312,32 @@ public class AST2CPPTests extends AST2TestBase {
assertSame(qt.getType(), A); assertSame(qt.getType(), A);
} }
// class A { A(void); A(const A &); }; // template<typename T> struct C {
public void testConstructors() throws Exception { // C(const C<T>& c) {}
IASTTranslationUnit tu = parse(getAboveComment(), CPP); // };
// struct D {
// typedef const D& TD;
// D(TD c) {}
// };
// struct E {
// E();
// };
// typedef E F;
// F::E() {}
public void testImplicitConstructors_360223() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
ICPPClassType c= bh.assertNonProblem("C", 0);
ICPPConstructor[] ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; c= bh.assertNonProblem("D", 0);
IASTCompositeTypeSpecifier compSpec = (IASTCompositeTypeSpecifier) decl.getDeclSpecifier(); ctors = c.getConstructors();
ICPPClassType A = (ICPPClassType) compSpec.getName().resolveBinding(); assertEquals(1, ctors.length);
ICPPConstructor[] ctors = A.getConstructors(); assertFalse(ctors[0].isImplicit());
assertNotNull(ctors); IBinding ctor= bh.assertNonProblem("E() {}", 1);
assertEquals(ctors.length, 2); assertTrue(ctor instanceof ICPPConstructor);
assertEquals(0, ctors[0].getParameters().length);
assertEquals(1, ctors[1].getParameters().length);
IType t = ctors[1].getParameters()[0].getType();
assertTrue(t instanceof ICPPReferenceType);
assertTrue(((ICPPReferenceType) t).getType() instanceof IQualifierType);
IQualifierType qt = (IQualifierType) ((ICPPReferenceType) t).getType();
assertTrue(qt.isConst());
assertSame(qt.getType(), A);
} }
// class A { ~A(); }; // class A { ~A(); };
@ -9636,34 +9664,6 @@ public class AST2CPPTests extends AST2TestBase {
parseAndCheckBindings(); parseAndCheckBindings();
} }
// template<typename T> struct C {
// C(const C<T>& c) {}
// };
// struct D {
// typedef const D& TD;
// D(TD c) {}
// };
// struct E {
// E();
// };
// typedef E F;
// F::E(){}
public void testImplicitCtors_360223() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
ICPPClassType c= bh.assertNonProblem("C", 0);
ICPPConstructor[] ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
c= bh.assertNonProblem("D", 0);
ctors = c.getConstructors();
assertEquals(1, ctors.length);
assertFalse(ctors[0].isImplicit());
IBinding ctor= bh.assertNonProblem("E(){}", 1);
assertTrue(ctor instanceof ICPPConstructor);
}
// struct S; // struct S;
// struct S { // struct S {
// S(); // S();

View file

@ -28,7 +28,6 @@ import org.eclipse.cdt.core.parser.IToken;
*/ */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public enum OverloadableOperator { public enum OverloadableOperator {
GT(">"), GT(">"),
LT("<"), LT("<"),
NOT("!"), NOT("!"),
@ -87,7 +86,6 @@ public enum OverloadableOperator {
return rep; return rep;
} }
/** /**
* Returns true if the given name equals 'operator new' * Returns true if the given name equals 'operator new'
* or 'operator new[]'. * or 'operator new[]'.