]> granicus.if.org Git - clang/commitdiff
Basic: [asmSymbolicName] follows the same rule as numbers in asm inputs
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 11 Jan 2015 09:57:13 +0000 (09:57 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 11 Jan 2015 09:57:13 +0000 (09:57 +0000)
Input constraints like "0" and "[foo]" should be treated the same when
it comes to their corresponding output constraint.

This fixes PR21850.

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

lib/Basic/TargetInfo.cpp
test/Sema/asm.c

index 15b8c83d1b360b52f4a78667679c5efbaf6f1d6a..535c87ec1158e99170e210c86dc693efb2a480af 100644 (file)
@@ -583,6 +583,10 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
       if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
         return false;
 
+      // A number must refer to an output only operand.
+      if (OutputConstraints[Index].isReadWrite())
+        return false;
+
       Info.setTiedOperand(Index, OutputConstraints[Index]);
       break;
     }
index 10d845e3d0bb1b00cefed45586f6486f4ecea9b7..f386f520be4db00655f403dd32c99319a247c20a 100644 (file)
@@ -190,3 +190,10 @@ void fn4() {
           : "=r"(l)
           : "#m"(l)); // expected-error {{invalid input constraint '#m' in asm}}
 }
+
+void fn5() {
+  int l;
+    __asm__(""
+          : [g] "+r"(l)
+          : "[g]"(l)); // expected-error {{invalid input constraint '[g]' in asm}}
+}