+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*.
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);
}
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)
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)
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)
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)
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)
/* 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;
}
}
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)
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);
}
}
#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);
+}