This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to warn about non-register matching asm operands
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Dec 2003 22:11:35 -0500
- Subject: PATCH to warn about non-register matching asm operands
In the thread discussing my recent patch to the libstdc++ atomicity asm
expressions, it came up that read-write constraints are converted to
matching constraints, and therefore inappropriate for use with non-register
constraints. I've already corrected the documentation accordingly, and
this patch introduces warnings about such unsafe usage.
Tested x86_64-pc-linux-gnu, applied to trunk.
2003-12-19 Jason Merrill <jason@redhat.com>
* stmt.c (parse_output_constraint): Warn about in-out constraint
that doesn't allow a register.
(parse_input_constraint): Warn about matching constraint that
doesn't allow a register.
*** stmt.c.~1~ 2003-12-19 17:33:34.000000000 -0500
--- stmt.c 2003-12-18 16:24:41.000000000 -0500
*************** parse_output_constraint (const char **co
*** 1254,1259 ****
--- 1254,1262 ----
break;
}
+ if (*is_inout && !*allows_reg)
+ warning ("read-write constraint does not allow a register");
+
return true;
}
*************** parse_input_constraint (const char **con
*** 1269,1274 ****
--- 1272,1278 ----
const char *orig_constraint = constraint;
size_t c_len = strlen (constraint);
size_t j;
+ bool saw_match = false;
/* Assume the constraint doesn't allow the use of either
a register or memory. */
*************** parse_input_constraint (const char **con
*** 1320,1325 ****
--- 1324,1331 ----
char *end;
unsigned long match;
+ saw_match = true;
+
match = strtoul (constraint + j, &end, 10);
if (match >= (unsigned long) noutputs)
{
*************** parse_input_constraint (const char **con
*** 1384,1389 ****
--- 1390,1398 ----
break;
}
+ if (saw_match && !*allows_reg)
+ warning ("matching constraint does not allow a register");
+
return true;
}