Skip to content

Commit 7bd8a16

Browse files
authored
[X86] Don't allow '+f' as an inline asm constraint. (#113871)
f cannot be used as an output constraint. We already errored for '=f' but not '+f'. Fixes #113692.
1 parent 67bcce2 commit 7bd8a16

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ bool X86TargetInfo::validateAsmConstraint(
14651465
}
14661466
case 'f': // Any x87 floating point stack register.
14671467
// Constraint 'f' cannot be used for output operands.
1468-
if (Info.ConstraintStr[0] == '=')
1468+
if (Info.ConstraintStr[0] == '=' || Info.ConstraintStr[0] == '+')
14691469
return false;
14701470
Info.setAllowsRegister();
14711471
return true;

clang/test/Sema/asm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ double f_output_constraint(void) {
204204
return result;
205205
}
206206

207+
double f_output_constraint_2(void) {
208+
double result;
209+
__asm("foo1": "+f" (result)); // expected-error {{invalid output constraint '+f' in asm}}
210+
return result;
211+
}
212+
207213
void fn1(void) {
208214
int l;
209215
__asm__(""

0 commit comments

Comments
 (0)