+1999-05-30 Mark Mitchell <mark@codesourcery.com>
+
+ * decl.c (start_decl): Move checks on initialization to ...
+ (cp_finish_decl): Here. Tidy formatting slightly.
+
1999-05-28 Mark Mitchell <mark@codesourcery.com>
* decl.c (add_binding): Don't complain about a redeclaration of a
break;
default:
- if (! processing_template_decl)
- {
- if (type != error_mark_node)
- {
- if (TYPE_SIZE (type) != NULL_TREE
- && ! TREE_CONSTANT (TYPE_SIZE (type)))
- {
- cp_error
- ("variable-sized object `%D' may not be initialized",
- decl);
- initialized = 0;
- }
-
- if (TREE_CODE (type) == ARRAY_TYPE
- && TYPE_SIZE (complete_type (TREE_TYPE (type))) == NULL_TREE)
- {
- cp_error
- ("elements of array `%#D' have incomplete type", decl);
- initialized = 0;
- }
- }
- }
+ break;
}
if (initialized)
goto finish_end0;
}
+
/* Take care of TYPE_DECLs up front. */
if (TREE_CODE (decl) == TYPE_DECL)
{
DECL_CONTEXT (decl) == NULL_TREE, at_eof);
goto finish_end;
}
+
if (TREE_CODE (decl) != FUNCTION_DECL)
- {
- ttype = target_type (type);
- }
+ ttype = target_type (type);
if (! DECL_EXTERNAL (decl) && TREE_READONLY (decl)
&& TYPE_NEEDS_CONSTRUCTING (type))
{
-
/* Currently, GNU C++ puts constants in text space, making them
impossible to initialize. In the future, one would hope for
an operating system which understood the difference between
init = NULL_TREE;
}
+ /* Check for certain invalid initializations. */
+ if (init)
+ {
+ if (TYPE_SIZE (type) && !TREE_CONSTANT (TYPE_SIZE (type)))
+ {
+ cp_error ("variable-sized object `%D' may not be initialized", decl);
+ init = NULL_TREE;
+ }
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && !TYPE_SIZE (complete_type (TREE_TYPE (type))))
+ {
+ cp_error ("elements of array `%#D' have incomplete type", decl);
+ init = NULL_TREE;
+ }
+ }
+
GNU_xref_decl (current_function_decl, decl);
core_type = type;