diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1996-01-01 09:30:37 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1996-01-01 09:30:37 -0500 |
commit | ed244fc2cd6a4e643b30e8e67617d94cb7034018 (patch) | |
tree | d6073ae99257b925607a9f630ac7db176f649733 | |
parent | e11fa86f42d5ab49ac1bf77a17c69dcc04862f52 (diff) | |
download | gcc-ed244fc2cd6a4e643b30e8e67617d94cb7034018.zip gcc-ed244fc2cd6a4e643b30e8e67617d94cb7034018.tar.gz gcc-ed244fc2cd6a4e643b30e8e67617d94cb7034018.tar.bz2 |
(finish_struct): Warn if field with enumeral type is narrower than
values of that type.
From-SVN: r10928
-rw-r--r-- | gcc/c-decl.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 51b9636..121424d 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1,5 +1,5 @@ /* Process declarations and variables for C compiler. - Copyright (C) 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1988, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. This file is part of GNU CC. @@ -5569,6 +5569,13 @@ finish_struct (t, fieldlist, attributes) { register int width = TREE_INT_CST_LOW (DECL_INITIAL (x)); + if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE + && (width < min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)), + TREE_UNSIGNED (TREE_TYPE (x))) + || width < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)), + TREE_UNSIGNED (TREE_TYPE (x))))) + warning_with_decl (x, "`%s' is narrower than values of its type"); + DECL_FIELD_SIZE (x) = width; DECL_BIT_FIELD (x) = DECL_C_BIT_FIELD (x) = 1; DECL_INITIAL (x) = NULL; |