From: David Majnemer Date: Sun, 11 Jan 2015 10:22:41 +0000 (+0000) Subject: Basic: Numeric constraints are multidigit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30e99c2392679daa94bd32d83141f2f4cff1e874;p=clang Basic: Numeric constraints are multidigit Clang would treat the digits in an "11m" input constraint separately as if it was handling constraint 1 twice instead of constraint 11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225606 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 535c87ec11..84cdaab517 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -548,11 +548,17 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints, default: // Check if we have a matching constraint if (*Name >= '0' && *Name <= '9') { - unsigned i = *Name - '0'; + const char *DigitStart = Name; + while (Name[1] >= '0' && Name[1] <= '9') + Name++; + const char *DigitEnd = Name; + unsigned i; + if (StringRef(DigitStart, DigitEnd - DigitStart + 1) + .getAsInteger(10, i)) + return false; // Check if matching constraint is out of bounds. - if (i >= NumOutputs) - return false; + if (i >= NumOutputs) return false; // A number must refer to an output only operand. if (OutputConstraints[i].isReadWrite()) diff --git a/test/Sema/asm.c b/test/Sema/asm.c index f386f520be..41a8265600 100644 --- a/test/Sema/asm.c +++ b/test/Sema/asm.c @@ -197,3 +197,10 @@ void fn5() { : [g] "+r"(l) : "[g]"(l)); // expected-error {{invalid input constraint '[g]' in asm}} } + +void fn6() { + int a; + __asm__("" + : "=rm"(a), "=rm"(a) + : "11m"(a)) // expected-error {{invalid input constraint '11m' in asm}} +}