diff options
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmtAsm.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 93faf2d151f9..10fa24682f9c 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -296,6 +296,14 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, checkExprMemoryConstraintCompat(*this, OutputExpr, Info, false)) return StmtError(); + // Disallow _ExtInt, since the backends tend to have difficulties with + // non-normal sizes. + if (OutputExpr->getType()->isExtIntType()) + return StmtError( + Diag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_type) + << OutputExpr->getType() << 0 /*Input*/ + << OutputExpr->getSourceRange()); + OutputConstraintInfos.push_back(Info); // If this is dependent, just continue. @@ -420,6 +428,12 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, } } + if (InputExpr->getType()->isExtIntType()) + return StmtError( + Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_type) + << InputExpr->getType() << 1 /*Output*/ + << InputExpr->getSourceRange()); + InputConstraintInfos.push_back(Info); const Type *Ty = Exprs[i]->getType().getTypePtr(); @@ -478,10 +492,10 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, // Look for the correct constraint index. unsigned ConstraintIdx = Piece.getOperandNo(); + unsigned NumOperands = NS->getNumOutputs() + NS->getNumInputs(); // Labels are the last in the Exprs list. - if (NS->isAsmGoto() && ConstraintIdx >= NS->getNumInputs()) + if (NS->isAsmGoto() && ConstraintIdx >= NumOperands) continue; - unsigned NumOperands = NS->getNumOutputs() + NS->getNumInputs(); // Look for the (ConstraintIdx - NumOperands + 1)th constraint with // modifier '+'. if (ConstraintIdx >= NumOperands) { @@ -892,6 +906,15 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, SourceLocation EndLoc) { bool IsSimple = (NumOutputs != 0 || NumInputs != 0); setFunctionHasBranchProtectedScope(); + + for (uint64_t I = 0; I < NumOutputs + NumInputs; ++I) { + if (Exprs[I]->getType()->isExtIntType()) + return StmtError( + Diag(Exprs[I]->getBeginLoc(), diag::err_asm_invalid_type) + << Exprs[I]->getType() << (I < NumOutputs) + << Exprs[I]->getSourceRange()); + } + MSAsmStmt *NS = new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, IsSimple, /*IsVolatile*/ true, AsmToks, NumOutputs, NumInputs, |