aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-08-28 18:02:04 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-08-28 18:02:04 +0000
commit9048891ff983d0681c116c6e8f1073aa31bdd6e8 (patch)
tree0fc94a01394e02a6767d142c443252f479cbc37f
parent4ef1c99433a5147f0f75d0dc6ba75af95ee79a68 (diff)
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
-rw-r--r--include/clang/AST/Expr.h2
-rw-r--r--lib/AST/Expr.cpp5
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp4
-rw-r--r--test/Sema/PR2727.c5
4 files changed, 16 insertions, 0 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 00de0233b4..b84ca020a1 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -540,6 +540,8 @@ public:
Expr(SizeOfAlignOfTypeExprClass, resultType),
isSizeof(issizeof), Ty(argType), OpLoc(op), RParenLoc(rp) {}
+ virtual void Destroy(ASTContext& C);
+
bool isSizeOf() const { return isSizeof; }
QualType getArgumentType() const { return Ty; }
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index a7e49d0efc..49c76a89d8 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1236,6 +1236,11 @@ int64_t UnaryOperator::evaluateOffsetOf(ASTContext& C) const
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
//===----------------------------------------------------------------------===//
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 1cdd798a39..e302f2b9ec 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -352,6 +352,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
TheModule.addTypeName(TypeName, Res);
return Res;
}
+
+ case Type::BlockPointer: {
+ assert(0 && "FIXME: Cannot get type of block pointer.");
+ }
}
// FIXME: implement.
diff --git a/test/Sema/PR2727.c b/test/Sema/PR2727.c
new file mode 100644
index 0000000000..faf934d947
--- /dev/null
+++ b/test/Sema/PR2727.c
@@ -0,0 +1,5 @@
+int f (int x)
+{
+ // sizeof applied to a type should not delete the type.
+ return sizeof (int[x]);
+}