Basic: [asmSymbolicName] follows the same rule as numbers in asm inputs
Input constraints like "0" and "[foo]" should be treated the same when
it comes to their corresponding output constraint.
This fixes PR21850.
llvm-svn: 225605
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 15b8c83..535c87e 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -583,6 +583,10 @@
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;
}
diff --git a/clang/test/Sema/asm.c b/clang/test/Sema/asm.c
index 10d845e..f386f52 100644
--- a/clang/test/Sema/asm.c
+++ b/clang/test/Sema/asm.c
@@ -190,3 +190,10 @@
: "=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}}
+}