]> granicus.if.org Git - clang/commitdiff
Don't insert an extra ParenExpr around asm operands.
authorEli Friedman <eli.friedman@gmail.com>
Sun, 3 May 2009 07:49:42 +0000 (07:49 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 3 May 2009 07:49:42 +0000 (07:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70673 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmt.cpp
lib/Sema/SemaStmt.cpp

index c692a18ed9da74399ec214579822e78f5c05e82b..d0d462b66ce859b21d72b18d9d8a5d8cc69087fb 100644 (file)
@@ -1272,7 +1272,9 @@ bool Parser::ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &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;
index d1246d28b6d3f95cd99c8d1a9fa395a478708c24..808368906bbf44f3fabfecb73d94c870c249b31c 100644 (file)
@@ -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<ParenExpr>(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<ParenExpr>(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());
       }
     }