1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

226308: Disable fix for 224364

This commit is contained in:
Andrew Ferguson 2008-04-14 11:06:30 +00:00
parent cba049ddbe
commit d29b51bbd4
7 changed files with 149 additions and 18 deletions

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
@ -18,22 +18,24 @@ import org.eclipse.cdt.core.model.tests.CModelElementsTests;
import org.eclipse.cdt.core.model.tests.StructuralCModelElementsTests;
import org.eclipse.cdt.core.parser.tests.ast2.DOMGCCParserExtensionTestSuite;
import org.eclipse.cdt.core.parser.tests.ast2.DOMParserTestSuite;
import org.eclipse.cdt.core.parser.tests.ast2.SemanticsTests;
import org.eclipse.cdt.core.parser.tests.scanner.ScannerTestSuite;
/**
* Combines all tests for the parsers.
*/
public class ParserTestSuite extends TestCase {
public static Test suite() {
public static Test suite() {
TestSuite suite= new TestSuite(ParserTestSuite.class.getName());
suite.addTestSuite(ArrayUtilsTest.class);
suite.addTestSuite(CharArrayUtilsTest.class);
suite.addTestSuite(CModelElementsTests.class);
suite.addTestSuite(StructuralCModelElementsTests.class);
suite.addTestSuite(ObjectMapTest.class );
suite.addTest( ScannerTestSuite.suite() );
suite.addTest( DOMParserTestSuite.suite() );
suite.addTest( DOMGCCParserExtensionTestSuite.suite() );
suite.addTestSuite(ObjectMapTest.class);
suite.addTestSuite(SemanticsTests.class);
suite.addTest(ScannerTestSuite.suite());
suite.addTest(DOMParserTestSuite.suite());
suite.addTest(DOMGCCParserExtensionTestSuite.suite());
return suite;
}
}
}

View file

@ -0,0 +1,109 @@
/*******************************************************************************
* Copyright (c) 2008 Symbian Software Systems 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
/**
* Directly tests parts of the semantics package
*/
public class SemanticsTests extends AST2BaseTest {
// class A {};
// class B {};
//
// class X {
// public:
// // unary
// A* operator !() { return new A(); } // logical not
// B* operator &() { return new B(); } // address of
// A* operator ~() { return new A(); } // one's complement
// B* operator *() { return new B(); } // ptr deference
// A* operator +() { return new A(); } // unary plus
// A* operator -() { return new A(); } // unary negation
// void operator ->() {} // Member selection
// X& operator++(); // Prefix increment operator.
// X operator++(int); // Postfix increment operator.
// X& operator--(); // Prefix decrement operator.
// X operator--(int); // Postfix decrement operator.
//
// // binary
// void operator ,(int x) {} // comma
// void operator ,(long x) {} // comma (overloaded)
// void operator !=(int x) {} // NE
// void operator !=(long x){} // NE (overloaded)
// void operator %(int x) {} // modulus
// void operator %=(int x) {} // modulus with assignment
// void operator &(int x) {} // bitwise AND
// void operator &&(A a) {} // logical AND
// void operator &=(A a) {} // Bitwise AND/assignment
// void operator *(B b) {} // multiplication
// void operator *=(X x) {} // multiplication with assignment
// void operator +(X x) {} // Addition
// A operator +=(int y) {} // Addition with assignment
// B operator -(X x) {} // Subtraction
// void operator -=(int y) {} // Subtraction with assignment
// void operator ->*(int z){} // ptr-to-member selection
// void operator /(int x) {} // division
// void operator /=(int y) {} // division with assignment
// void operator <(int x) {} // LT
// void operator <<(int x) {} // L shift
// void operator <<=(int x){} // L shift assignment
// void operator <=(int x) {} // LE
// void operator =(int x) {} // assignment
// void operator ==(int y) {} // EQ
// void operator >(int x) {} // GT
// void operator >=(int y) {} // GE
// void operator >>(int x) {} // R shift
// void operator >>=(int x){} // R shift with assignment
// void operator ^(int x) {} // XOR
// void operator ^=(int x) {} // XOR assignment
// void operator |(int x) {} // Bitwise OR
// void operator |=(int x) {} // Bitwise OR with assignment
// void operator ||(int x) {} // logical OR
//
// void operator()(int a, int b, int c) {} // function call
//
// void operator[](int i) {} // subscripting
//
// operator A(); // conversion
// operator B(); // conversion
// };
public void testGetDeclaredConversionOperators() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ICPPClassType c= ba.assertNonProblem("X {", 1, ICPPClassType.class);
ICPPMethod[] cops= SemanticUtil.getDeclaredConversionOperators(c);
assertEquals(2, cops.length);
Set actual= new HashSet();
actual.add(cops[0].getName()); actual.add(cops[1].getName());
Set expected= new HashSet();
expected.add("operator A"); expected.add("operator B");
assertEquals(expected, actual);
}
public void testIsConversionOperator() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ICPPClassType c= ba.assertNonProblem("X {", 1, ICPPClassType.class);
ICPPMethod[] dms= c.getDeclaredMethods();
assertEquals(48, dms.length);
for(ICPPMethod method : dms) {
String name= method.getName();
boolean isConvOp= name.equals("operator A") || name.equals("operator B");
assertEquals(isConvOp, SemanticUtil.isConversionOperator(method));
}
}
}

View file

@ -1291,7 +1291,7 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
// E e;
// foo(e);
// }
public void testUserDefinedConversionOperator_224364() throws Exception {
public void _testUserDefinedConversionOperator_224364() throws Exception {
IBinding ca= getBindingFromASTName("C c;", 1);
assertInstance(ca, ICPPClassType.class);

View file

@ -953,7 +953,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// C<X> cx;
// foo(cx);
// }
public void testUserDefinedConversionOperator_224364() throws Exception {
public void _testUserDefinedConversionOperator_224364() throws Exception {
IBinding ca= getBindingFromASTName("C<A>", 4);
assertInstance(ca, ICPPClassType.class);
assertInstance(ca, ICPPTemplateInstance.class);

View file

@ -41,6 +41,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
@ -147,8 +151,15 @@ class Conversions {
}
}
boolean checkConversionOperators=
(SemanticUtil.ENABLE_224364 && s instanceof ICPPClassType)
|| (s instanceof CPPClassType
|| s instanceof CPPClassTemplate
|| s instanceof CPPClassSpecialization
|| s instanceof CPPClassInstance);
//conversion operators
if( s instanceof ICPPClassType ){
if (checkConversionOperators) {
ICPPMethod [] ops = SemanticUtil.getConversionOperators((ICPPClassType)s);
if( ops.length > 0 && !(ops[0] instanceof IProblemBinding) ){
Cost [] costs = null;

View file

@ -42,16 +42,23 @@ public class SemanticUtil {
*/
private static final CharArraySet cas= new CharArraySet(OverloadableOperator.values().length);
/**
* Switch for enabling fix for bug 224364
*/
public static final boolean ENABLE_224364= System.getProperty("cdt.enable.224364") != null; //$NON-NLS-1$
static {
final int OPERATOR_SPC= OPERATOR_CHARS.length + 1;
for(OverloadableOperator op : OverloadableOperator.values()) {
cas.put(op.toCharArray());
char[] name= op.toCharArray();
cas.put(CharArrayUtils.subarray(name, OPERATOR_SPC, name.length));
}
}
/**
* Returns a list of ICPPMethod objects representing all conversion operators
* declared by the specified class. It does not include inherited methods. Conversion
* operators can not be implicit.
* declared by the specified class. This does not include inherited methods. Conversion
* operators cannot be implicit.
* @param clazz
* @return List of ICPPMethod
*/
@ -70,8 +77,8 @@ public class SemanticUtil {
/**
* Returns a list of ICPPMethod objects representing all conversion operators
* declared by the specified class and its ancestors. It does not include inherited
* methods. Conversion operators can not be implicit.
* declared by the specified class and its ancestors. This includes inherited
* methods. Conversion operators cannot be implicit.
* @param clazz
* @return List of ICPPMethod
*/
@ -120,9 +127,9 @@ public class SemanticUtil {
/**
* @param method
* @return true is the specified method is a conversion operator
* @return true if the specified method is a conversion operator
*/
private static final boolean isConversionOperator(ICPPMethod method) {
public static final boolean isConversionOperator(ICPPMethod method) {
boolean result= false;
if(!method.isImplicit()) {
final char[] name= method.getNameCharArray();

View file

@ -264,7 +264,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if ((pdomBinding instanceof PDOMCPPClassInstance || pdomBinding instanceof PDOMCPPDeferredClassInstance) && binding instanceof ICPPClassType) {
// Add instantiated constructors to the index (bug 201174).
addConstructors(pdomBinding, (ICPPClassType) binding);
addConversionOperators(pdomBinding, (ICPPClassType) binding);
if(SemanticUtil.ENABLE_224364) {
addConversionOperators(pdomBinding, (ICPPClassType) binding);
}
}
}
} catch (DOMException e) {