1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-31 12:55:40 +02:00

Destructors are neither const nor volatile, bug 269655.

This commit is contained in:
Markus Schorn 2009-03-24 18:12:47 +00:00
parent b90a03c48b
commit dfc2eb9c52
3 changed files with 4 additions and 7 deletions

View file

@ -133,8 +133,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
if (!ia.hasUserDeclaredDestructor()) { if (!ia.hasUserDeclaredDestructor()) {
//destructor: ~A() //destructor: ~A()
// a destructor can be called for const and volatile objects ICPPFunctionType ft= CPPVisitor.createImplicitFunctionType(new CPPBasicType(IBasicType.t_unspecified, 0), voidPs, false, false);
ICPPFunctionType ft= CPPVisitor.createImplicitFunctionType(new CPPBasicType(IBasicType.t_unspecified, 0), voidPs, true, true);
char[] dtorName = CharArrayUtils.concat("~".toCharArray(), className); //$NON-NLS-1$ char[] dtorName = CharArrayUtils.concat("~".toCharArray(), className); //$NON-NLS-1$
ICPPMethod m = new CPPImplicitMethod(this, dtorName, ft, voidPs); ICPPMethod m = new CPPImplicitMethod(this, dtorName, ft, voidPs);
implicits[i++] = m; implicits[i++] = m;

View file

@ -2200,7 +2200,8 @@ public class CPPSemantics {
final IType thisType = data.getImpliedObjectArgument(); final IType thisType = data.getImpliedObjectArgument();
if (ASTInternal.isStatic(fn, false)) { if (fn instanceof ICPPMethod &&
(((ICPPMethod) fn).isDestructor() || ASTInternal.isStatic(fn, false))) {
// 13.3.1-4 for static member functions, the implicit object parameter always matches, no cost // 13.3.1-4 for static member functions, the implicit object parameter always matches, no cost
cost = new Cost(thisType, implicitType, Rank.IDENTITY); cost = new Cost(thisType, implicitType, Rank.IDENTITY);
} else if (thisType == null) { } else if (thisType == null) {

View file

@ -1558,10 +1558,7 @@ public class CPPVisitor extends ASTQueries {
returnType = getPointerTypes(returnType, fnDtor); returnType = getPointerTypes(returnType, fnDtor);
} }
// a destructor can be called for const and volatile objects IType type = new CPPFunctionType(returnType, pTypes, fnDtor.isConst(), fnDtor.isVolatile());
final char[] lookupKey = name.getLookupKey();
final boolean isDestructor= lookupKey.length > 0 && lookupKey[0]=='~';
IType type = new CPPFunctionType(returnType, pTypes, isDestructor || fnDtor.isConst(), isDestructor || fnDtor.isVolatile());
final IASTDeclarator nested = fnDtor.getNestedDeclarator(); final IASTDeclarator nested = fnDtor.getNestedDeclarator();
if (nested != null) { if (nested != null) {
return createType(type, nested); return createType(type, nested);