summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-07-05 22:20:17 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-07-05 22:20:17 +0000
commitfce3dd98703caff8417ff75475ccda38d8713ff0 (patch)
treecf39293c4e7511a91c63086d665961115b3fee08 /src
parente74c15dd5a9968ad17b67667c7e70e5988897ea9 (diff)
downloadcoreutils-fce3dd98703caff8417ff75475ccda38d8713ff0.tar.xz
(DECIMAL_DIGIT_ACCUMULATE): Generate a hard error
(not just a warning) if GCC is used and the types don't match.
Diffstat (limited to 'src')
-rw-r--r--src/system.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/system.h b/src/system.h
index a22bfb04e..e3a99ab5d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -811,13 +811,18 @@ ptr_align (void const *ptr, size_t alignment)
then don't update Accum and return false to indicate it would
overflow. Otherwise, set Accum to that new value and return true.
Verify at compile-time that Type is Accum's type, and that Type is
- unsigned. Accum must be an object, so that we can take its address.
- Accum and Digit_val may be evaluated multiple times. */
+ unsigned. Accum must be an object, so that we can take its
+ address. Accum and Digit_val may =be evaluated multiple times.
+
+ The "Added check" below is not strictly required, but it causes GCC
+ to return a nonzero exit status instead of merely a warning
+ diagnostic, and that is more useful. */
#define DECIMAL_DIGIT_ACCUMULATE(Accum, Digit_val, Type) \
( \
(void) (&(Accum) == (Type *) NULL), /* The type matches. */ \
verify_expr (! TYPE_SIGNED (Type)), /* The type is unsigned. */ \
+ verify_expr (sizeof (Accum) == sizeof (Type)), /* Added check. */ \
(((Type) -1 / 10 < (Accum) \
|| (Type) ((Accum) * 10 + (Digit_val)) < (Accum)) \
? false : (((Accum) = (Accum) * 10 + (Digit_val)), true)) \