Commit 1f36f7b3 by Jim Meyering Committed by Jim Meyering

genmodes: don't truncate a mode name of length >= 7

* genmodes.c (make_complex_modes): Don't truncate a mode name of
length 7 or more when prepending a "C".  Suggested by Richard Guenther.

From-SVN: r186628
parent b7262828
2012-04-20 Jim Meyering <meyering@redhat.com>
* genmodes.c (make_complex_modes): Don't truncate a mode name of
length 7 or more when prepending a "C". Suggested by Richard Guenther.
2012-04-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com> 2012-04-20 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR rtl-optimization/44214 PR rtl-optimization/44214
......
...@@ -427,7 +427,6 @@ make_complex_modes (enum mode_class cl, ...@@ -427,7 +427,6 @@ make_complex_modes (enum mode_class cl,
{ {
struct mode_data *m; struct mode_data *m;
struct mode_data *c; struct mode_data *c;
char buf[8];
enum mode_class cclass = complex_class (cl); enum mode_class cclass = complex_class (cl);
if (cclass == MODE_RANDOM) if (cclass == MODE_RANDOM)
...@@ -435,6 +434,7 @@ make_complex_modes (enum mode_class cl, ...@@ -435,6 +434,7 @@ make_complex_modes (enum mode_class cl,
for (m = modes[cl]; m; m = m->next) for (m = modes[cl]; m; m = m->next)
{ {
char *p, *buf;
size_t m_len; size_t m_len;
/* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */ /* Skip BImode. FIXME: BImode probably shouldn't be MODE_INT. */
...@@ -442,40 +442,34 @@ make_complex_modes (enum mode_class cl, ...@@ -442,40 +442,34 @@ make_complex_modes (enum mode_class cl,
continue; continue;
m_len = strlen (m->name); m_len = strlen (m->name);
if (m_len >= sizeof buf) /* The leading "1 +" is in case we prepend a "C" below. */
{ buf = (char *) xmalloc (1 + m_len + 1);
error ("%s:%d:mode name \"%s\" is too long",
m->file, m->line, m->name);
continue;
}
/* Float complex modes are named SCmode, etc. /* Float complex modes are named SCmode, etc.
Int complex modes are named CSImode, etc. Int complex modes are named CSImode, etc.
This inconsistency should be eliminated. */ This inconsistency should be eliminated. */
p = 0;
if (cl == MODE_FLOAT) if (cl == MODE_FLOAT)
{ {
char *p, *q = 0;
/* We verified above that m->name+NUL fits in buf. */
memcpy (buf, m->name, m_len + 1); memcpy (buf, m->name, m_len + 1);
p = strchr (buf, 'F'); p = strchr (buf, 'F');
if (p == 0) if (p == 0 && strchr (buf, 'D') == 0)
q = strchr (buf, 'D');
if (p == 0 && q == 0)
{ {
error ("%s:%d: float mode \"%s\" has no 'F' or 'D'", error ("%s:%d: float mode \"%s\" has no 'F' or 'D'",
m->file, m->line, m->name); m->file, m->line, m->name);
free (buf);
continue; continue;
} }
if (p != 0)
*p = 'C';
else
snprintf (buf, sizeof buf, "C%s", m->name);
} }
if (p != 0)
*p = 'C';
else else
snprintf (buf, sizeof buf, "C%s", m->name); {
buf[0] = 'C';
memcpy (buf + 1, m->name, m_len + 1);
}
c = new_mode (cclass, xstrdup (buf), file, line); c = new_mode (cclass, buf, file, line);
c->component = m; c->component = m;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment