]> granicus.if.org Git - clang/commitdiff
Sema: Permit array l-values in asm output operands
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 29 Dec 2014 10:29:53 +0000 (10:29 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 29 Dec 2014 10:29:53 +0000 (10:29 +0000)
GCC permits array l-values in asm output operands even though they
aren't modifiable l-values.  We used to permit it but this behavior
regressed in r224916.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224918 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaStmtAsm.cpp
test/SemaCXX/statements.cpp

index 24a91716cb8527ad5b047f2943ea0b4ba946939b..afd785c5dfb4bb1aec48596e481f4faa13ba47a3 100644 (file)
@@ -156,6 +156,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple,
     case Expr::MLV_Valid:
       // Cool, this is an lvalue.
       break;
+    case Expr::MLV_ArrayType:
+      // This is OK too.
+      break;
     case Expr::MLV_LValueCast: {
       const Expr *LVal = OutputExpr->IgnoreParenNoopCasts(Context);
       if (!getLangOpts().HeinousExtensions) {
index 22648f3a081ce85ecbf26d7e6cec8ad1c4ff0f2b..efca37dcba1297aa2b9d1918c0417f990c6f308d 100644 (file)
@@ -30,3 +30,7 @@ void test4(int) {            // expected-note{{possible target for call}}
   // expected-error@+1{{overloaded function could not be resolved}}
   __asm__ ("":"+r" (test4)); // expected-error{{invalid lvalue in asm output}}
 }
+void test5() {
+  char buf[1];
+  __asm__ ("":"+r" (buf));
+}