[cfe-commits] r118146 - in /cfe/trunk: lib/Basic/TargetInfo.cpp test/Sema/asm.c
Anders Carlsson
andersca at mac.com
Tue Nov 2 19:54:51 PDT 2010
Author: andersca
Date: Tue Nov 2 21:54:51 2010
New Revision: 118146
URL: http://llvm.org/viewvc/llvm-project?rev=118146&view=rev
Log:
When setting a tied check if it's already tied. If it's tied to another constraint it's invalid. Fixes PR3905.
Modified:
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/test/Sema/asm.c
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=118146&r1=118145&r2=118146&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue Nov 2 21:54:51 2010
@@ -354,6 +354,11 @@
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 @@
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;
}
Modified: cfe/trunk/test/Sema/asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/asm.c?rev=118146&r1=118145&r2=118146&view=diff
==============================================================================
--- cfe/trunk/test/Sema/asm.c (original)
+++ cfe/trunk/test/Sema/asm.c Tue Nov 2 21:54:51 2010
@@ -81,7 +81,13 @@
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}}
}
More information about the cfe-commits
mailing list