]> granicus.if.org Git - clang/commitdiff
A number in an input constraint can't point to a read-write ('+') constraint. Fixes...
authorAnders Carlsson <andersca@mac.com>
Wed, 3 Nov 2010 02:22:29 +0000 (02:22 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 3 Nov 2010 02:22:29 +0000 (02:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118145 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 6ef306d27e757013a5ba461ab483495d78ef4121..947cbfc3f6d2c28520970afab3c02b67c63a7940 100644 (file)
@@ -350,6 +350,10 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
         if (i >= NumOutputs)
           return false;
 
+        // A number must refer to an output only operand.
+        if (OutputConstraints[i].isReadWrite())
+          return false;
+
         // The constraint should have the same info as the respective
         // output constraint.
         Info.setTiedOperand(i, OutputConstraints[i]);
index 52611faf3dbc1a86bbcd684ff6c36838f460d4ba..73d081ddd3858848afb601193376b749192982c4 100644 (file)
@@ -79,3 +79,9 @@ int test7(unsigned long long b) {
 
 // <rdar://problem/7574870>
 asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
+
+// PR3904
+int test8(int i) {
+  // A number in an input constraint can't point to a read-write constraint.
+  asm ("" : "+r" (i), "=r"(i) :  "0" (i)); // expected-error{{invalid input constraint '0' in asm}}
+}