Fix double-free error with sizeof applied to VLA types.

- PR2727.

Also, fix warning in CodeGenTypes for new BlockPointer type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55479 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2008-08-28 18:02:04 +00:00
Родитель 4ef1c99433
Коммит 9048891ff9
4 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -540,6 +540,8 @@ public:
Expr(SizeOfAlignOfTypeExprClass, resultType), Expr(SizeOfAlignOfTypeExprClass, resultType),
isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {} isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {}
virtual void Destroy(ASTContext& C);
bool isSizeOf() const { return isSizeof; } bool isSizeOf() const { return isSizeof; }
QualType getArgumentType() const { return Ty; } QualType getArgumentType() const { return Ty; }

Просмотреть файл

@ -1236,6 +1236,11 @@ int64_t UnaryOperator::evaluateOffsetOf(ASTContext& C) const
return ::evaluateOffsetOf(C, cast<Expr>(Val)) / CharSize; return ::evaluateOffsetOf(C, cast<Expr>(Val)) / CharSize;
} }
void SizeOfAlignOfTypeExpr::Destroy(ASTContext& C) {
// Override default behavior of traversing children. We do not want
// to delete the type.
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Child Iterators for iterating over subexpressions/substatements // Child Iterators for iterating over subexpressions/substatements
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

Просмотреть файл

@ -352,6 +352,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
TheModule.addTypeName(TypeName, Res); TheModule.addTypeName(TypeName, Res);
return Res; return Res;
} }
case Type::BlockPointer: {
assert(0 && "FIXME: Cannot get type of block pointer.");
}
} }
// FIXME: implement. // FIXME: implement.

5
test/Sema/PR2727.c Normal file
Просмотреть файл

@ -0,0 +1,5 @@
int f (int x)
{
// sizeof applied to a type should not delete the type.
return sizeof (int[x]);
}