]> granicus.if.org Git - clang/commitdiff
When setting a tied check if it's already tied. If it's tied to another constraint...
authorAnders Carlsson <andersca@mac.com>
Wed, 3 Nov 2010 02:54:51 +0000 (02:54 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 3 Nov 2010 02:54:51 +0000 (02:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118146 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 947cbfc3f6d2c28520970afab3c02b67c63a7940..1437a4ba015c2ba8e5444ef0872a046488e2db22 100644 (file)
@@ -354,6 +354,11 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
         if (OutputConstraints[i].isReadWrite())
           return false;
 
+        // If the constraint is already tied, it must be tied to the 
+        // same operand referenced to by the number.
+        if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
+          return false;
+
         // The constraint should have the same info as the respective
         // output constraint.
         Info.setTiedOperand(i, OutputConstraints[i]);
@@ -369,6 +374,11 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
       if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
         return false;
 
+      // If the constraint is already tied, it must be tied to the 
+      // same operand referenced to by the number.
+      if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
+        return false;
+
       Info.setTiedOperand(Index, OutputConstraints[Index]);
       break;
     }
index 73d081ddd3858848afb601193376b749192982c4..814849037911e399540fc8f03d69c5c293e63621 100644 (file)
@@ -81,7 +81,13 @@ int test7(unsigned long long b) {
 asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
 
 // PR3904
-int test8(int i) {
+void 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}}
+  asm("" : "+r" (i), "=r"(i) :  "0" (i)); // expected-error{{invalid input constraint '0' in asm}}
+}
+
+// PR3905
+void test9(int i) {
+  asm("" : [foo] "=r" (i), "=r"(i) : "1[foo]"(i)); // expected-error{{invalid input constraint '1[foo]' in asm}}
+  asm("" : [foo] "=r" (i), "=r"(i) : "[foo]1"(i)); // expected-error{{invalid input constraint '[foo]1' in asm}}
 }