2002-11-30 Mark Mitchell <mark@codesourcery.com>
+ PR c++/8227
+ * decl.c (layout_var_decl): Deal gracefully with erroneous types.
+ (check_initializer): Validate the type of the initialized
+ variable, even if the initializer is absent.
+ * typeck.c (cp_type_quals): Deal gracefully with erroneous types.
+
PR c++/8214
* typeck.c (convert_for_assignment): Do not use
decl_constant_value on the operand.
-2002-11-30 Mark Mitchell <mark@codesourcery.com>
-
PR c++/8511
* pt.c (instantiate_decl): Handle template friends defined outside
of the class correctly.
if (!DECL_EXTERNAL (decl))
complete_type (type);
if (!DECL_SIZE (decl)
+ && TREE_TYPE (decl) != error_mark_node
&& (COMPLETE_TYPE_P (type)
|| (TREE_CODE (type) == ARRAY_TYPE
&& !TYPE_DOMAIN (type)
the static initialization -- if any -- of DECL. */
DECL_INITIAL (decl) = NULL_TREE;
- /* Check the initializer. */
- if (init)
- {
- /* Things that are going to be initialized need to have complete
- type. */
- TREE_TYPE (decl) = type = complete_type (TREE_TYPE (decl));
+ /* Things that are going to be initialized need to have complete
+ type. */
+ TREE_TYPE (decl) = type = complete_type (TREE_TYPE (decl));
- if (type == error_mark_node)
- /* We will have already complained. */
- init = NULL_TREE;
- else if (COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type)))
- {
- error ("variable-sized object `%D' may not be initialized", decl);
- init = NULL_TREE;
- }
- else if (TREE_CODE (type) == ARRAY_TYPE
- && !COMPLETE_TYPE_P (complete_type (TREE_TYPE (type))))
- {
- error ("elements of array `%#D' have incomplete type", decl);
- init = NULL_TREE;
- }
- else if (TREE_CODE (type) != ARRAY_TYPE && !COMPLETE_TYPE_P (type))
- {
- error ("`%D' has incomplete type", decl);
- TREE_TYPE (decl) = error_mark_node;
- init = NULL_TREE;
- }
+ if (type == error_mark_node)
+ /* We will have already complained. */
+ init = NULL_TREE;
+ else if (init && COMPLETE_TYPE_P (type)
+ && !TREE_CONSTANT (TYPE_SIZE (type)))
+ {
+ error ("variable-sized object `%D' may not be initialized", decl);
+ init = NULL_TREE;
+ }
+ else if (TREE_CODE (type) == ARRAY_TYPE
+ && !COMPLETE_TYPE_P (complete_type (TREE_TYPE (type))))
+ {
+ error ("elements of array `%#D' have incomplete type", decl);
+ init = NULL_TREE;
+ }
+ else if (TREE_CODE (type) != ARRAY_TYPE && !COMPLETE_TYPE_P (type))
+ {
+ error ("`%D' has incomplete type", decl);
+ TREE_TYPE (decl) = error_mark_node;
+ init = NULL_TREE;
}
if (TREE_CODE (decl) == CONST_DECL)
code_pattern = DECL_TEMPLATE_RESULT (td);
- /* In the case of a friend temlpate whose definition is provided
+ /* In the case of a friend template whose definition is provided
outside the class, we may have too many arguments. Drop the ones
we don't need. */
args = get_innermost_template_args (gen_args,