diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-03-25 21:09:49 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-03-25 21:09:49 +0000 |
commit | c4fc3a2ba52d24195ab06388c662b118a2664358 (patch) | |
tree | 4139da3dca6baebf14abc1dc4326880dfcfd8871 /clang/lib/Sema/SemaStmtAsm.cpp | |
parent | 8c0d63c120cc76fefdb128d0b07b8b1cdf183c26 (diff) | |
download | bcm5719-llvm-c4fc3a2ba52d24195ab06388c662b118a2664358.tar.gz bcm5719-llvm-c4fc3a2ba52d24195ab06388c662b118a2664358.zip |
Emit an error message instead of crashing when dereferencing an incomplete pointer type.
If the ASM statement is dereferencing an incomplete pointer type, issue an error
instead of crashing.
<rdar://problem/12700799>
llvm-svn: 177915
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmtAsm.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 95964e20a7e..fc693e6cd78 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -124,11 +124,15 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, // Check that the output exprs are valid lvalues. Expr *OutputExpr = Exprs[i]; - if (CheckAsmLValue(OutputExpr, *this)) { + if (CheckAsmLValue(OutputExpr, *this)) return StmtError(Diag(OutputExpr->getLocStart(), - diag::err_asm_invalid_lvalue_in_output) - << OutputExpr->getSourceRange()); - } + diag::err_asm_invalid_lvalue_in_output) + << OutputExpr->getSourceRange()); + + if (RequireCompleteType(OutputExpr->getLocStart(), Exprs[i]->getType(), 0)) + return StmtError(Diag(OutputExpr->getLocStart(), + diag::err_dereference_incomplete_type) + << Exprs[i]->getType()); OutputConstraintInfos.push_back(Info); } @@ -181,11 +185,15 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, InputConstraintInfos.push_back(Info); const Type *Ty = Exprs[i]->getType().getTypePtr(); - if (Ty->isDependentType() || - RequireCompleteType(InputExpr->getLocStart(), - Exprs[i]->getType(), 0)) + if (Ty->isDependentType()) continue; + if (!Ty->isVoidType() || !Info.allowsMemory()) + if (RequireCompleteType(InputExpr->getLocStart(), Exprs[i]->getType(), 0)) + return StmtError(Diag(InputExpr->getLocStart(), + diag::err_dereference_incomplete_type) + << Exprs[i]->getType()); + unsigned Size = Context.getTypeSize(Ty); if (!Context.getTargetInfo().validateInputSize(Literal->getString(), Size)) |