Commit 1c609c4c by Nathan Sidwell Committed by Nathan Sidwell

decl.c (cp_finish_decl): Don't permit arrays of abstract or signature type.

	* decl.c (cp_finish_decl): Don't permit arrays of abstract or
	signature type.

From-SVN: r26706
parent 0c42bebf
1999-04-30 Nathan Sidwell <nathan@acm.org>
* decl.c (cp_finish_decl): Don't permit arrays of abstract or
signature type.
1999-04-29 Mark Mitchell <mark@codesourcery.com> 1999-04-29 Mark Mitchell <mark@codesourcery.com>
* decl2.c (do_static_destruction): Remove obsolete FIXME comment. * decl2.c (do_static_destruction): Remove obsolete FIXME comment.
......
...@@ -7704,6 +7704,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) ...@@ -7704,6 +7704,7 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
char *asmspec = NULL; char *asmspec = NULL;
int was_readonly = 0; int was_readonly = 0;
int already_used = 0; int already_used = 0;
tree core_type;
/* If this is 0, then we did not change obstacks. */ /* If this is 0, then we did not change obstacks. */
if (! decl) if (! decl)
...@@ -7859,6 +7860,10 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) ...@@ -7859,6 +7860,10 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
GNU_xref_decl (current_function_decl, decl); GNU_xref_decl (current_function_decl, decl);
core_type = type;
while (TREE_CODE (core_type) == ARRAY_TYPE)
core_type = TREE_TYPE (core_type);
if (TREE_CODE (decl) == FIELD_DECL) if (TREE_CODE (decl) == FIELD_DECL)
; ;
else if (TREE_CODE (decl) == CONST_DECL) else if (TREE_CODE (decl) == CONST_DECL)
...@@ -7907,14 +7912,11 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) ...@@ -7907,14 +7912,11 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
else if (TREE_CODE_CLASS (TREE_CODE (type)) == 't' else if (TREE_CODE_CLASS (TREE_CODE (type)) == 't'
&& (IS_AGGR_TYPE (type) || TYPE_NEEDS_CONSTRUCTING (type))) && (IS_AGGR_TYPE (type) || TYPE_NEEDS_CONSTRUCTING (type)))
{ {
tree ctype = type; if (! TYPE_NEEDS_CONSTRUCTING (core_type))
while (TREE_CODE (ctype) == ARRAY_TYPE)
ctype = TREE_TYPE (ctype);
if (! TYPE_NEEDS_CONSTRUCTING (ctype))
{ {
if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (ctype)) if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type))
cp_error ("structure `%D' with uninitialized const members", decl); cp_error ("structure `%D' with uninitialized const members", decl);
if (CLASSTYPE_REF_FIELDS_NEED_INIT (ctype)) if (CLASSTYPE_REF_FIELDS_NEED_INIT (core_type))
cp_error ("structure `%D' with uninitialized reference members", cp_error ("structure `%D' with uninitialized reference members",
decl); decl);
} }
...@@ -8183,17 +8185,17 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) ...@@ -8183,17 +8185,17 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
resume_temporary_allocation (); resume_temporary_allocation ();
if (type != error_mark_node if (type != error_mark_node
&& TYPE_LANG_SPECIFIC (type) && TYPE_LANG_SPECIFIC (core_type)
&& CLASSTYPE_ABSTRACT_VIRTUALS (type)) && CLASSTYPE_ABSTRACT_VIRTUALS (core_type))
abstract_virtuals_error (decl, type); abstract_virtuals_error (decl, core_type);
else if ((TREE_CODE (type) == FUNCTION_TYPE else if ((TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE) || TREE_CODE (type) == METHOD_TYPE)
&& TYPE_LANG_SPECIFIC (TREE_TYPE (type)) && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
&& CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (type))) && CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (type)))
abstract_virtuals_error (decl, TREE_TYPE (type)); abstract_virtuals_error (decl, TREE_TYPE (type));
if (TYPE_LANG_SPECIFIC (type) && IS_SIGNATURE (type)) if (TYPE_LANG_SPECIFIC (core_type) && IS_SIGNATURE (core_type))
signature_error (decl, type); signature_error (decl, core_type);
else if ((TREE_CODE (type) == FUNCTION_TYPE else if ((TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE) || TREE_CODE (type) == METHOD_TYPE)
&& TYPE_LANG_SPECIFIC (TREE_TYPE (type)) && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
......
// Build don't link:
// Origin: Adapted by Nathan Sidwell 29 Apr 1999 <nathan@acm.org>
// from a test case submitted by Corey Kosak <kosak@cs.cmu.edu>
// http://egcs.cygnus.com/ml/egcs-bugs/1999-04/msg00502.html
// We should not allow arrays of abstract type. [class.abstract/2]
struct cow_t {
virtual void f()=0; // ERROR - abstract
};
int main()
{
cow_t cow[2]; // ERROR - abstract class
cow[0].f();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment