]> granicus.if.org Git - clang/commitdiff
Basic: The asm constraint '#m' isn't valid, reject it
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 11 Jan 2015 09:39:03 +0000 (09:39 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 11 Jan 2015 09:39:03 +0000 (09:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225603 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 3162b7cde239eb12fc2c8b0b602cf3cf939e60c4..15b8c83d1b360b52f4a78667679c5efbaf6f1d6a 100644 (file)
@@ -491,6 +491,7 @@ bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
         Name++;
       if (Name[1] != ',')
         return false;
+      break;
     case '?': // Disparage slightly code.
     case '!': // Disparage severely.
     case '*': // Ignore for choosing register preferences.
@@ -623,9 +624,14 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
       break;
     case ',': // multiple alternative constraint.  Ignore comma.
       break;
+    case '#': // Ignore as constraint.
+      while (Name[1] && Name[1] != ',')
+        Name++;
+      if (Name[1] != ',')
+        return false;
+      break;
     case '?': // Disparage slightly code.
     case '!': // Disparage severely.
-    case '#': // Ignore as constraint.
     case '*': // Ignore for choosing register preferences.
       break;  // Pass them.
     }
index b4000cb5ff89c784b474c510e0ef545252ffeaf1..10d845e3d0bb1b00cefed45586f6486f4ecea9b7 100644 (file)
@@ -183,3 +183,10 @@ void fn3() {
  __asm__(""
           : "+#r"(l)); // expected-error {{invalid output constraint '+#r' in asm}}
 }
+
+void fn4() {
+  int l;
+ __asm__(""
+          : "=r"(l)
+          : "#m"(l)); // expected-error {{invalid input constraint '#m' in asm}}
+}