aboutsummaryrefslogtreecommitdiff
path: root/gcc/lra-constraints.c
diff options
context:
space:
mode:
authorVladimir N. Makarov <vmakarov@redhat.com>2021-03-20 10:50:03 -0400
committerVladimir N. Makarov <vmakarov@redhat.com>2021-03-20 10:52:10 -0400
commit8bf983c71e42d5a9f9df8a7dc436b30cd9da42f5 (patch)
treec3dde12b6a05c46a655d9f65255277edf0049b78 /gcc/lra-constraints.c
parent5f256a70a05fcfc5a1caf56678ceb12b4f87f781 (diff)
downloadgcc-8bf983c71e42d5a9f9df8a7dc436b30cd9da42f5.zip
gcc-8bf983c71e42d5a9f9df8a7dc436b30cd9da42f5.tar.gz
gcc-8bf983c71e42d5a9f9df8a7dc436b30cd9da42f5.tar.bz2
[PR99680] Check empty constraint before using CONSTRAINT_LEN.
It seems CONSTRAINT_LEN treats constraint '\0' as one having length 1. Therefore we read after the constraint string. The patch fixes it. gcc/ChangeLog: PR rtl-optimization/99680 * lra-constraints.c (skip_contraint_modifiers): Rename to skip_constraint_modifiers. (process_address_1): Check empty constraint before using CONSTRAINT_LEN.
Diffstat (limited to 'gcc/lra-constraints.c')
-rw-r--r--gcc/lra-constraints.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 698d8d0..fdfe953 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -3395,12 +3395,12 @@ equiv_address_substitution (struct address_info *ad)
/* Skip all modifiers and whitespaces in constraint STR and return the
result. */
static const char *
-skip_contraint_modifiers (const char *str)
+skip_constraint_modifiers (const char *str)
{
for (;;str++)
switch (*str)
{
- case '+' : case '&' : case '=': case '*': case ' ': case '\t':
+ case '+': case '&' : case '=': case '*': case ' ': case '\t':
case '$': case '^' : case '%': case '?': case '!':
break;
default: return str;
@@ -3451,13 +3451,13 @@ process_address_1 (int nop, bool check_only_p,
return false;
constraint
- = skip_contraint_modifiers (curr_static_id->operand[nop].constraint);
+ = skip_constraint_modifiers (curr_static_id->operand[nop].constraint);
if (IN_RANGE (constraint[0], '0', '9'))
{
char *end;
unsigned long dup = strtoul (constraint, &end, 10);
constraint
- = skip_contraint_modifiers (curr_static_id->operand[dup].constraint);
+ = skip_constraint_modifiers (curr_static_id->operand[dup].constraint);
}
cn = lookup_constraint (*constraint == '\0' ? "X" : constraint);
/* If we have several alternatives or/and several constraints in an
@@ -3465,10 +3465,10 @@ process_address_1 (int nop, bool check_only_p,
use unknown constraint. The exception is an address constraint. If
operand has one address constraint, probably all others constraints are
address ones. */
- if (get_constraint_type (cn) != CT_ADDRESS
- && *skip_contraint_modifiers (constraint
- + CONSTRAINT_LEN (constraint[0],
- constraint)) != '\0')
+ if (constraint[0] != '\0' && get_constraint_type (cn) != CT_ADDRESS
+ && *skip_constraint_modifiers (constraint
+ + CONSTRAINT_LEN (constraint[0],
+ constraint)) != '\0')
cn = CONSTRAINT__UNKNOWN;
if (insn_extra_address_constraint (cn)
/* When we find an asm operand with an address constraint that