From: Akira Hatanaka Date: Fri, 18 Jul 2014 23:30:30 +0000 (+0000) Subject: [X86 inline-asm] Error out on inline-asm constraint "=f". X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05e95a916abdf36231e02d14ad62f5cf5517686d;p=clang [X86 inline-asm] Error out on inline-asm constraint "=f". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213428 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 49e94442ab..fe72fe1e19 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -2927,6 +2927,13 @@ X86TargetInfo::validateAsmConstraint(const char *&Name, case 'm': // any MMX register, when inter-unit moves enabled. break; // falls through to setAllowsRegister. } + case 'f': // any x87 floating point stack register. + // Constraint 'f' cannot be used for output operands. + if (Info.ConstraintStr[0] == '=') + return false; + + Info.setAllowsRegister(); + return true; case 'a': // eax. case 'b': // ebx. case 'c': // ecx. @@ -2934,7 +2941,6 @@ X86TargetInfo::validateAsmConstraint(const char *&Name, case 'S': // esi. case 'D': // edi. case 'A': // edx:eax. - case 'f': // any x87 floating point stack register. case 't': // top of floating point stack. case 'u': // second from top of floating point stack. case 'q': // Any register accessible as [r]l: a, b, c, and d. diff --git a/test/Sema/asm.c b/test/Sema/asm.c index 22b74974ce..89c8c574eb 100644 --- a/test/Sema/asm.c +++ b/test/Sema/asm.c @@ -157,3 +157,9 @@ struct foo { }; register struct foo bar asm("sp"); // expected-error {{bad type for named register variable}} register float baz asm("sp"); // expected-error {{bad type for named register variable}} + +double f_output_constraint(void) { + double result; + __asm("foo1": "=f" (result)); // expected-error {{invalid output constraint '=f' in asm}} + return result; +}