summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAlexander Musman <alexander.musman@gmail.com>2015-06-05 13:40:59 +0000
committerAlexander Musman <alexander.musman@gmail.com>2015-06-05 13:40:59 +0000
commiteae29e247e6b7a0d5fdbd7b1b912278f3cfcb926 (patch)
treea68b8459d628d3b3effab82427ab3306b9612661 /clang/lib/Sema
parent5a589ad6035e2cc6776cc8fb255c27b38cab6c5c (diff)
downloadbcm5719-llvm-eae29e247e6b7a0d5fdbd7b1b912278f3cfcb926.tar.gz
bcm5719-llvm-eae29e247e6b7a0d5fdbd7b1b912278f3cfcb926.zip
Fix for PR14269: Clang crashes when a bit field is used as inline assembler
input / output with memory constraint. One generally can't get address of a bit field, so the general solution is to error on such cases. GCC does the same. Patch by Andrey Bokhanko Differential Revision: http://reviews.llvm.org/D10086 llvm-svn: 239153
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaStmtAsm.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index 9f48616ea5b..d19d8819d8e 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -154,6 +154,14 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
if (CheckNakedParmReference(OutputExpr, *this))
return StmtError();
+ // Bitfield can't be referenced with a pointer.
+ if (Info.allowsMemory() && OutputExpr->refersToBitField())
+ return StmtError(Diag(OutputExpr->getLocStart(),
+ diag::err_asm_bitfield_in_memory_constraint)
+ << 1
+ << Info.getConstraintStr()
+ << OutputExpr->getSourceRange());
+
OutputConstraintInfos.push_back(Info);
// If this is dependent, just continue.
@@ -230,6 +238,14 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
if (CheckNakedParmReference(InputExpr, *this))
return StmtError();
+ // Bitfield can't be referenced with a pointer.
+ if (Info.allowsMemory() && InputExpr->refersToBitField())
+ return StmtError(Diag(InputExpr->getLocStart(),
+ diag::err_asm_bitfield_in_memory_constraint)
+ << 0
+ << Info.getConstraintStr()
+ << InputExpr->getSourceRange());
+
// Only allow void types for memory constraints.
if (Info.allowsMemory() && !Info.allowsRegister()) {
if (CheckAsmLValue(InputExpr, *this))
OpenPOWER on IntegriCloud