aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-02-02 04:38:30 +0000
committerRichard Stallman <rms@gnu.org>1993-02-02 04:38:30 +0000
commit90374cc2ff1f4a466bca44cbd7ceb6964d09fd1d (patch)
tree3ae728f583948d5fe6958d534bb38bed67ec108e /gcc
parente0f776fbcb705304c3e6fa1fe0ba0e530f85e4a2 (diff)
downloadgcc-90374cc2ff1f4a466bca44cbd7ceb6964d09fd1d.zip
gcc-90374cc2ff1f4a466bca44cbd7ceb6964d09fd1d.tar.gz
gcc-90374cc2ff1f4a466bca44cbd7ceb6964d09fd1d.tar.bz2
(finish_decl, grokdeclarator, finish_struct): Report overflows in storage sizes.
(finish_decl, grokdeclarator, finish_struct): Report overflows in storage sizes. (build_enumerator): Report overflows in enumerators. From-SVN: r3402
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-decl.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 1a32e3c..96c1523 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -3308,9 +3308,11 @@ finish_decl (decl, init, asmspec_tree)
}
if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
- && DECL_SIZE (decl) != 0
- && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
- error_with_decl (decl, "storage size of `%s' isn't constant");
+ && DECL_SIZE (decl) != 0)
+ if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
+ constant_expression_warning (DECL_SIZE (decl));
+ else
+ error_with_decl (decl, "storage size of `%s' isn't constant");
}
/* Output the assembler code and/or RTL code for variables and functions,
@@ -3961,6 +3963,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
pedwarn ("ANSI C forbids zero-size array `%s'", name);
if (TREE_CODE (size) == INTEGER_CST)
{
+ constant_expression_warning (size);
if (INT_CST_LT (size, integer_zero_node))
{
error ("size of array `%s' is negative", name);
@@ -4896,11 +4899,14 @@ finish_struct (t, fieldlist)
/* Detect invalid bit-field size. */
if (DECL_INITIAL (x))
STRIP_NOPS (DECL_INITIAL (x));
- if (DECL_INITIAL (x) && TREE_CODE (DECL_INITIAL (x)) != INTEGER_CST)
- {
- error_with_decl (x, "bit-field `%s' width not an integer constant");
- DECL_INITIAL (x) = NULL;
- }
+ if (DECL_INITIAL (x))
+ if (TREE_CODE (DECL_INITIAL (x)) == INTEGER_CST)
+ constant_expression_warning (DECL_INITIAL (x));
+ else
+ {
+ error_with_decl (x, "bit-field `%s' width not an integer constant");
+ DECL_INITIAL (x) = NULL;
+ }
/* Detect invalid bit-field type. */
if (DECL_INITIAL (x)
@@ -5308,12 +5314,15 @@ build_enumerator (name, value)
if (value)
STRIP_TYPE_NOPS (value);
- if (value != 0 && TREE_CODE (value) != INTEGER_CST)
- {
- error ("enumerator value for `%s' not integer constant",
- IDENTIFIER_POINTER (name));
- value = 0;
- }
+ if (value != 0)
+ if (TREE_CODE (value) == INTEGER_CST)
+ constant_expression_warning (value);
+ else
+ {
+ error ("enumerator value for `%s' not integer constant",
+ IDENTIFIER_POINTER (name));
+ value = 0;
+ }
/* Default based on previous value. */
/* It should no longer be possible to have NON_LVALUE_EXPR