aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 9a4977d09b..fa4c9d620a 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1049,18 +1049,23 @@ Sema::ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
if (isType) {
ArgTy = QualType::getFromOpaquePtr(TyOrEx);
Range = ArgRange;
+
+ // Verify that the operand is valid.
+ if (CheckSizeOfAlignOfOperand(ArgTy, OpLoc, Range, isSizeof))
+ return ExprError();
} else {
// Get the end location.
Expr *ArgEx = (Expr *)TyOrEx;
Range = ArgEx->getSourceRange();
ArgTy = ArgEx->getType();
+
+ // Verify that the operand is valid.
+ if (CheckSizeOfAlignOfOperand(ArgTy, OpLoc, Range, isSizeof)) {
+ DeleteExpr(ArgEx);
+ return ExprError();
+ }
}
- // Verify that the operand is valid.
- // FIXME: This might leak the expression.
- if (CheckSizeOfAlignOfOperand(ArgTy, OpLoc, Range, isSizeof))
- return ExprError();
-
// C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
return Owned(new (Context) SizeOfAlignOfExpr(isSizeof, isType, TyOrEx,
Context.getSizeType(), OpLoc,