From 72056a237c536ee63285ab0850cb50f299281767 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 3 May 2009 07:49:42 +0000 Subject: [PATCH] Don't insert an extra ParenExpr around asm operands. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70673 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseStmt.cpp | 4 +++- lib/Sema/SemaStmt.cpp | 17 ++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index c692a18ed9..d0d462b66c 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1272,7 +1272,9 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl &Names, } // Read the parenthesized expression. - OwningExprResult Res(ParseSimpleParenExpression()); + SourceLocation OpenLoc = ConsumeParen(); + OwningExprResult Res(ParseExpression()); + MatchRHSPunctuation(tok::r_paren, OpenLoc); if (Res.isInvalid()) { SkipUntil(tok::r_paren); return true; diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index d1246d28b6..808368906b 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -940,12 +940,11 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, << Info.getConstraintStr()); // Check that the output exprs are valid lvalues. - // FIXME: Operands to asms should not be parsed as ParenExprs. - ParenExpr *OutputExpr = cast(Exprs[i]); + Expr *OutputExpr = Exprs[i]; if (CheckAsmLValue(OutputExpr, *this)) { - return StmtError(Diag(OutputExpr->getSubExpr()->getLocStart(), + return StmtError(Diag(OutputExpr->getLocStart(), diag::err_asm_invalid_lvalue_in_output) - << OutputExpr->getSubExpr()->getSourceRange()); + << OutputExpr->getSourceRange()); } OutputConstraintInfos.push_back(Info); @@ -969,23 +968,23 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, << Info.getConstraintStr()); } - ParenExpr *InputExpr = cast(Exprs[i]); + Expr *InputExpr = Exprs[i]; // Only allow void types for memory constraints. if (Info.allowsMemory() && !Info.allowsRegister()) { if (CheckAsmLValue(InputExpr, *this)) - return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(), + return StmtError(Diag(InputExpr->getLocStart(), diag::err_asm_invalid_lvalue_in_input) << Info.getConstraintStr() - << InputExpr->getSubExpr()->getSourceRange()); + << InputExpr->getSourceRange()); } if (Info.allowsRegister()) { if (InputExpr->getType()->isVoidType()) { - return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(), + return StmtError(Diag(InputExpr->getLocStart(), diag::err_asm_invalid_type_in_input) << InputExpr->getType() << Info.getConstraintStr() - << InputExpr->getSubExpr()->getSourceRange()); + << InputExpr->getSourceRange()); } } -- 2.40.0