diff options
author | Richard Stallman <rms@gnu.org> | 1993-03-22 07:04:18 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1993-03-22 07:04:18 +0000 |
commit | b4892310d56ec029bae5195e1f4c385d598303cb (patch) | |
tree | 67507de1211ad1f112d12543bcec402265f65c76 /gcc/c-decl.c | |
parent | dc437e1631c88df258470bb942c5257e6a2c0c01 (diff) | |
download | gcc-b4892310d56ec029bae5195e1f4c385d598303cb.zip gcc-b4892310d56ec029bae5195e1f4c385d598303cb.tar.gz gcc-b4892310d56ec029bae5195e1f4c385d598303cb.tar.bz2 |
(init_decl_processing): Set that var.
(finish_incomplete_decl): New function.
(complete_array_type): Use 0 as default maxindex.
From-SVN: r3823
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 49d5ba3..0acd8ff 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -711,6 +711,27 @@ print_lang_identifier (file, node, indent) print_node (file, "limbo value", IDENTIFIER_LIMBO_VALUE (node), indent + 4); } +/* Hook called at end of compilation to assume 1 elt + for a top-level array decl that wasn't complete before. */ + +void +finish_incomplete_decl (decl) + tree decl; +{ + if (TREE_CODE (decl) == VAR_DECL && TREE_TYPE (decl) != error_mark_node) + { + tree type = TREE_TYPE (decl); + if (TREE_CODE (type) == ARRAY_TYPE + && TYPE_DOMAIN (type) == 0 + && TREE_CODE (decl) != TYPE_DECL) + { + complete_array_type (type, NULL_TREE, 1); + + layout_decl (decl, 0); + } + } +} + /* Create a new `struct binding_level'. */ static @@ -2990,6 +3011,8 @@ init_decl_processing () init_format_info_table (); init_iterators (); + + incomplete_decl_finalize_hook = finish_incomplete_decl; } /* Return a definition for a builtin function named NAME and whose data type @@ -3359,8 +3382,13 @@ finish_decl (decl, init, asmspec_tree) { if (do_default) error_with_decl (decl, "array size missing in `%s'"); - else if (!pedantic && TREE_STATIC (decl)) - /* ??? Perhaps should set TREE_PUBLIC here? */ + /* If a `static' var's size isn't known, + make it extern as well as static, so it does not get + allocated. + If it is not `static', then do not mark extern; + finish_incomplete_decl will give it a default size + and it will get allocated. */ + else if (!pedantic && TREE_STATIC (decl) && ! TREE_PUBLIC (decl)) DECL_EXTERNAL (decl) = 1; } @@ -3580,14 +3608,14 @@ complete_array_type (type, initial_value, do_default) value = 1; /* Prevent further error messages. */ - maxindex = build_int_2 (1, 0); + maxindex = build_int_2 (0, 0); } } if (!maxindex) { if (do_default) - maxindex = build_int_2 (1, 0); + maxindex = build_int_2 (0, 0); value = 2; } |