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(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]); +}