Browse Source

Remove duplicate code and provide a function for generating internally consistent 'value out of range' messages

jimb-rda-nptl-branch
Nick Clifton 23 years ago
parent
commit
e59763172f
  1. 18
      gas/ChangeLog
  2. 3
      gas/as.h
  3. 12
      gas/config/tc-alpha.c
  4. 12
      gas/config/tc-arc.c
  5. 12
      gas/config/tc-mn10200.c
  6. 12
      gas/config/tc-mn10300.c
  7. 9
      gas/config/tc-ppc.c
  8. 12
      gas/config/tc-s390.c
  9. 19
      gas/config/tc-v850.c
  10. 81
      gas/messages.c

18
gas/ChangeLog

@ -1,3 +1,21 @@
2004-05-06 Nick Clifton <nickc@redhat.com>
* messages (as_internal_value_out_of_range): Print a message about
a value being out of range. Be consistent about whether the
values are printed in decimal or hexadecimal.
(as_warn_value_out_of_range): Generate a warning message about an
out of range value.
(as_bad_value_out_of_range): Generate an error message about an
out of range value.
* as.h: Prototype the new functions.
* config/tc-alpha.c (insert_operand): Use new function.
* config/tc-arc.c (arc_insert_operand): Likewise.
* config/tc-mn10200.c (mn10200_insert_operand): Likewise.
* config/tc-mn10300.c (mn10300_insert_operand): Likewise.
* config/tc-ppc.c (ppc_insert_operand): Likewise.
* config/tc-s390.c (s390_insert_operand): Likewise.
* config/tc-v850.c (v850_insert_operand): Likewise.
2004-05-05 Alexandre Oliva <aoliva@redhat.com>
* configure.in: Set em=linux for frv-*-*linux*.

3
gas/as.h

@ -562,6 +562,9 @@ void sprint_value (char *buf, addressT value);
int had_errors (void);
int had_warnings (void);
void as_warn_value_out_of_range (char *, offsetT, offsetT, offsetT, char *, unsigned);
void as_bad_value_out_of_range (char *, offsetT, offsetT, offsetT, char *, unsigned);
void print_version_id (void);
char *app_push (void);
char *atof_ieee (char *str, int what_kind, LITTLENUM_TYPE * words);

12
gas/config/tc-alpha.c

@ -2373,17 +2373,7 @@ insert_operand (insn, operand, val, file, line)
}
if (val < min || val > max)
{
const char *err =
_("operand out of range (%s not between %d and %d)");
char buf[sizeof (val) * 3 + 2];
sprint_value (buf, val);
if (file)
as_warn_where (file, line, err, buf, min, max);
else
as_warn (err, buf, min, max);
}
as_warn_value_out_of_range (_("operand"), val, min, max, file, line);
}
if (operand->insert)

12
gas/config/tc-arc.c

@ -328,17 +328,7 @@ arc_insert_operand (insn, operand, mods, reg, val, file, line)
test = val;
if (test < (offsetT) min || test > (offsetT) max)
{
const char *err =
"operand out of range (%s not between %ld and %ld)";
char buf[100];
sprint_value (buf, test);
if (file == (char *) NULL)
as_warn (err, buf, min, max);
else
as_warn_where (file, line, err, buf, min, max);
}
as_warn_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line);
}
if (operand->insert)

12
gas/config/tc-mn10200.c

@ -1342,17 +1342,7 @@ mn10200_insert_operand (insnp, extensionp, operand, val, file, line, shift)
test = val;
if (test < (offsetT) min || test > (offsetT) max)
{
const char *err =
_("operand out of range (%s not between %ld and %ld)");
char buf[100];
sprint_value (buf, test);
if (file == (char *) NULL)
as_warn (err, buf, min, max);
else
as_warn_where (file, line, err, buf, min, max);
}
as_warn_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line);
}
if ((operand->flags & MN10200_OPERAND_EXTENDED) == 0)

12
gas/config/tc-mn10300.c

@ -2584,17 +2584,7 @@ mn10300_insert_operand (insnp, extensionp, operand, val, file, line, shift)
test = val;
if (test < (offsetT) min || test > (offsetT) max)
{
const char *err =
_("operand out of range (%s not between %ld and %ld)");
char buf[100];
sprint_value (buf, test);
if (file == (char *) NULL)
as_warn (err, buf, min, max);
else
as_warn_where (file, line, err, buf, min, max);
}
as_warn_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line);
}
if ((operand->flags & MN10300_OPERAND_SPLIT) != 0)

9
gas/config/tc-ppc.c

@ -1457,14 +1457,7 @@ ppc_insert_operand (insn, operand, val, file, line)
test = val;
if (test < (offsetT) min || test > (offsetT) max)
{
const char *err =
_("operand out of range (%s not between %ld and %ld)");
char buf[100];
sprint_value (buf, test);
as_bad_where (file, line, err, buf, min, max);
}
as_bad_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line);
}
if (operand->insert)

12
gas/config/tc-s390.c

@ -601,21 +601,15 @@ s390_insert_operand (insn, operand, val, file, line)
/* Check for underflow / overflow. */
if (uval < min || uval > max)
{
const char *err =
"operand out of range (%s not between %ld and %ld)";
char buf[100];
if (operand->flags & S390_OPERAND_LENGTH)
{
uval++;
min++;
max++;
}
sprint_value (buf, uval);
if (file == (char *) NULL)
as_bad (err, buf, (int) min, (int) max);
else
as_bad_where (file, line, err, buf, (int) min, (int) max);
as_bad_value_out_of_range (_("operand"), uval, (offsetT) min, (offsetT) max, file, line);
return;
}
}

19
gas/config/tc-v850.c

@ -1618,10 +1618,7 @@ v850_insert_operand (insn, operand, val, file, line, str)
if (val < (offsetT) min || val > (offsetT) max)
{
/* xgettext:c-format */
const char *err =
_("operand out of range (%s not between %ld and %ld)");
char buf[100];
char buf [128];
/* Restore min and mix to expected values for decimal ranges. */
if ((operand->flags & V850_OPERAND_SIGNED)
@ -1633,18 +1630,12 @@ v850_insert_operand (insn, operand, val, file, line, str)
min = 0;
if (str)
{
sprintf (buf, "%s: ", str);
sprint_value (buf + strlen (buf), val);
}
sprintf (buf, "%s: ", str);
else
sprint_value (buf, val);
buf[0] = 0;
strcat (buf, _("operand"));
if (file == (char *) NULL)
as_warn (err, buf, min, max);
else
as_warn_where (file, line, err, buf, min, max);
as_bad_value_out_of_range (buf, val, (offsetT) min, (offsetT) max, file, line);
}
}

81
gas/messages.c

@ -503,3 +503,84 @@ sprint_value (char *buf, valueT val)
#endif
abort ();
}
#define HEX_MAX_THRESHOLD 1024
#define HEX_MIN_THRESHOLD -(HEX_MAX_THRESHOLD)
static void
as_internal_value_out_of_range (char * prefix,
offsetT val,
offsetT min,
offsetT max,
char * file,
unsigned line,
int bad)
{
const char * err;
if (prefix == NULL)
prefix = "";
#ifdef BFD_ASSEMBLER
if ( val < HEX_MAX_THRESHOLD
&& min < HEX_MAX_THRESHOLD
&& max < HEX_MAX_THRESHOLD
&& val > HEX_MIN_THRESHOLD
&& min > HEX_MIN_THRESHOLD
&& max > HEX_MIN_THRESHOLD)
#endif
{
/* xgettext:c-format */
err = _("%s out of range (%d is not between %d and %d)");
if (bad)
as_bad_where (file, line, err, prefix, val, min, max);
else
as_warn_where (file, line, err, prefix, val, min, max);
}
#ifdef BFD_ASSEMBLER
else
{
char val_buf [sizeof (val) * 3 + 2];
char min_buf [sizeof (val) * 3 + 2];
char max_buf [sizeof (val) * 3 + 2];
if (sizeof (val) > sizeof (bfd_vma))
abort ();
sprintf_vma (val_buf, val);
sprintf_vma (min_buf, min);
sprintf_vma (max_buf, max);
/* xgettext:c-format. */
err = _("%s out of range (0x%s is not between 0x%s and 0x%s)");
if (bad)
as_bad_where (file, line, err, prefix, val_buf, min_buf, max_buf);
else
as_warn_where (file, line, err, prefix, val_buf, min_buf, max_buf);
}
#endif
}
void
as_warn_value_out_of_range (char * prefix,
offsetT value,
offsetT min,
offsetT max,
char * file,
unsigned line)
{
as_internal_value_out_of_range (prefix, value, min, max, file, line, 0);
}
void
as_bad_value_out_of_range (char * prefix,
offsetT value,
offsetT min,
offsetT max,
char * file,
unsigned line)
{
as_internal_value_out_of_range (prefix, value, min, max, file, line, 1);
}

Loading…
Cancel
Save