Commit 560ad596 by Mark Mitchell Committed by Mark Mitchell

re PR c++/11703 (Problem with using enum in placement delete)

	PR c++/11703
	* call.c (type_passed_as): Use TYPE_SIZE, not TYPE_PRECISION to
	determine whether or not to promote types.
	(convert_for_arg_passing): Likewise.
	* decl2.c (cp_build_parm_decl): Do not set DECL_ARG_TYPE in
	templates.
	* pt.c (tsubst_decl): Do not expect it to be set.

	PR c++/9512
	PR c++/10923
	* cp-tree.h (check_elaborated_type_specifier): Declare.
	(handle_class_head): Remove.
	(note_got_semicolon): Likewise.
	(note_list_got_semicolon): Likewise.
	(finish_class_definition): Likewise.
	* decl.c (check_elaborated_type_specifier): Make it public.
	Robustify.
	(handle_class_head): Remove.
	* parser.c (cp_parser_elaborated_type_specifier): Use
	check_elaborated_type_specifier.
	(cp_parser_class_specifier): Do not call finish_class_definition.
	(cp_parser_class_head): Or handle_class_head.  Check for
	over-qualified names.
	* semantics.c (finish_class_definition): Remove.

	* parser.c (cp_parser_check_for_definition_in_return_type): New
	function.
	(cp_parser_simple_declaration): Adjust call to
	cp_parser_init_declarator.
	(cp_parser_decl_specifier_seq): Change type of
	declares_class_or_enum parameter.
	(cp_parser_explicit_instantiation): Adjust accordingly.
	(cp_parser_type_specifier): Change type of
	declares_class_or_enum parameter.
	(cp_parser_init_declarator): Add declares_class_or_enum
	parameter.
	(cp_parser_parameter_declaration): Adjust call to
	cp_parser_decl_specifier_seq.
	(cp_parser_function_definition): Likewise.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_single_declaration): Likewise.

	* cp-tree.h (lang_type_class): Remove has_call_overloaded,
	has_array_ref_overloaded, has_arrow_overloaded, and got_semicolon.
	(TYPE_OVERLOADS_CALL_EXPR): Remove.
	(TYPE_OVERLOADS_ARRAY_REF): Likewise.
	(TYPE_OVERLOADS_ARROW): Likewise.
	(CLASSTYPE_GOT_SEMICOLON): Likewise.
	* class.c (check_bases): Do not set them.
	(finish_struct_1): Likewise.
	* decl.c (cp_finish_decl): Do not set CLASSTYPE_GOT_SEMICOLON.
	(build_ptrmemfunc_type): Likewise.
	(grok_op_properties): Do not set TYPE_OVERLOADS_*.
	(start_function): Do not check CLASSTYPE_GOT_SEMICOLON.
	* decl2.c (grokfield): Do not set CLASSTYPE_GOT_SEMICOLON.
	* lex.c (note_got_semicolon): Remove.
	(note_list_got_semicolon): Likewise.
	* parser.c (cp_parser_simple_declaration): Do not call
	note_list_got_semicolon.
	* pt.c (list_eq): Remove.
	(lookup_template_class): Do not set CLASSTYPE_GOT_SEMICOLON.
	(instantiate_class_template): Do not set TYPE_OVERLOADS*.
	(instantiate_class_template): Do not set CLASSTYPE_GOT_SEMICOLON.
	* ptree.c (cxx_print_type): Do not print them.
	* semantics.c (finish_member_class_template): Do not call
	note_list_got_semicolon.

	* g++.dg/parse/ret-type2.C: New test.

	PR c++/11703
	* g++.dg/init/new8.C: New test.

	PR c++/10923
	* g++.dg/parse/typedef5.C: New test.

	PR c++/9512
	* g++.dg/parse/qualified2.C: New test.
	* g++.old-deja/g++.other/decl5.C: Mark one more instance of
	invalid code.

From-SVN: r70391
parent 35e6511a
2003-08-12 Mark Mitchell <mark@codesourcery.com>
PR c++/11703
* call.c (type_passed_as): Use TYPE_SIZE, not TYPE_PRECISION to
determine whether or not to promote types.
(convert_for_arg_passing): Likewise.
* decl2.c (cp_build_parm_decl): Do not set DECL_ARG_TYPE in
templates.
* pt.c (tsubst_decl): Do not expect it to be set.
PR c++/9512
PR c++/10923
* cp-tree.h (check_elaborated_type_specifier): Declare.
(handle_class_head): Remove.
(note_got_semicolon): Likewise.
(note_list_got_semicolon): Likewise.
(finish_class_definition): Likewise.
* decl.c (check_elaborated_type_specifier): Make it public.
Robustify.
(handle_class_head): Remove.
* parser.c (cp_parser_elaborated_type_specifier): Use
check_elaborated_type_specifier.
(cp_parser_class_specifier): Do not call finish_class_definition.
(cp_parser_class_head): Or handle_class_head. Check for
over-qualified names.
* semantics.c (finish_class_definition): Remove.
* parser.c (cp_parser_check_for_definition_in_return_type): New
function.
(cp_parser_simple_declaration): Adjust call to
cp_parser_init_declarator.
(cp_parser_decl_specifier_seq): Change type of
declares_class_or_enum parameter.
(cp_parser_explicit_instantiation): Adjust accordingly.
(cp_parser_type_specifier): Change type of
declares_class_or_enum parameter.
(cp_parser_init_declarator): Add declares_class_or_enum
parameter.
(cp_parser_parameter_declaration): Adjust call to
cp_parser_decl_specifier_seq.
(cp_parser_function_definition): Likewise.
(cp_parser_member_declaration): Likewise.
(cp_parser_single_declaration): Likewise.
* cp-tree.h (lang_type_class): Remove has_call_overloaded,
has_array_ref_overloaded, has_arrow_overloaded, and got_semicolon.
(TYPE_OVERLOADS_CALL_EXPR): Remove.
(TYPE_OVERLOADS_ARRAY_REF): Likewise.
(TYPE_OVERLOADS_ARROW): Likewise.
(CLASSTYPE_GOT_SEMICOLON): Likewise.
* class.c (check_bases): Do not set them.
(finish_struct_1): Likewise.
* decl.c (cp_finish_decl): Do not set CLASSTYPE_GOT_SEMICOLON.
(build_ptrmemfunc_type): Likewise.
(grok_op_properties): Do not set TYPE_OVERLOADS_*.
(start_function): Do not check CLASSTYPE_GOT_SEMICOLON.
* decl2.c (grokfield): Do not set CLASSTYPE_GOT_SEMICOLON.
* lex.c (note_got_semicolon): Remove.
(note_list_got_semicolon): Likewise.
* parser.c (cp_parser_simple_declaration): Do not call
note_list_got_semicolon.
* pt.c (list_eq): Remove.
(lookup_template_class): Do not set CLASSTYPE_GOT_SEMICOLON.
(instantiate_class_template): Do not set TYPE_OVERLOADS*.
(instantiate_class_template): Do not set CLASSTYPE_GOT_SEMICOLON.
* ptree.c (cxx_print_type): Do not print them.
* semantics.c (finish_member_class_template): Do not call
note_list_got_semicolon.
2003-08-11 Aldy Hernandez <aldyh@redhat.com> 2003-08-11 Aldy Hernandez <aldyh@redhat.com>
* call.c (standard_conversion): Opaque pointers interconvert. * call.c (standard_conversion): Opaque pointers interconvert.
......
...@@ -4330,7 +4330,8 @@ type_passed_as (tree type) ...@@ -4330,7 +4330,8 @@ type_passed_as (tree type)
type = build_reference_type (type); type = build_reference_type (type);
else if (PROMOTE_PROTOTYPES else if (PROMOTE_PROTOTYPES
&& INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) && INT_CST_LT_UNSIGNED (TYPE_SIZE (type),
TYPE_SIZE (integer_type_node)))
type = integer_type_node; type = integer_type_node;
return type; return type;
...@@ -4348,7 +4349,8 @@ convert_for_arg_passing (tree type, tree val) ...@@ -4348,7 +4349,8 @@ convert_for_arg_passing (tree type, tree val)
val = build1 (ADDR_EXPR, build_reference_type (type), val); val = build1 (ADDR_EXPR, build_reference_type (type), val);
else if (PROMOTE_PROTOTYPES else if (PROMOTE_PROTOTYPES
&& INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) && INT_CST_LT_UNSIGNED (TYPE_SIZE (type),
TYPE_SIZE (integer_type_node)))
val = perform_integral_promotions (val); val = perform_integral_promotions (val);
return val; return val;
} }
......
...@@ -1284,9 +1284,6 @@ check_bases (tree t, ...@@ -1284,9 +1284,6 @@ check_bases (tree t,
TYPE_HAS_COMPLEX_ASSIGN_REF (t) TYPE_HAS_COMPLEX_ASSIGN_REF (t)
|= TYPE_HAS_COMPLEX_ASSIGN_REF (basetype); |= TYPE_HAS_COMPLEX_ASSIGN_REF (basetype);
TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (basetype); TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (basetype);
TYPE_OVERLOADS_CALL_EXPR (t) |= TYPE_OVERLOADS_CALL_EXPR (basetype);
TYPE_OVERLOADS_ARRAY_REF (t) |= TYPE_OVERLOADS_ARRAY_REF (basetype);
TYPE_OVERLOADS_ARROW (t) |= TYPE_OVERLOADS_ARROW (basetype);
TYPE_POLYMORPHIC_P (t) |= TYPE_POLYMORPHIC_P (basetype); TYPE_POLYMORPHIC_P (t) |= TYPE_POLYMORPHIC_P (basetype);
CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t)
|= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype);
...@@ -4977,7 +4974,6 @@ finish_struct_1 (tree t) ...@@ -4977,7 +4974,6 @@ finish_struct_1 (tree t)
/* If this type was previously laid out as a forward reference, /* If this type was previously laid out as a forward reference,
make sure we lay it out again. */ make sure we lay it out again. */
TYPE_SIZE (t) = NULL_TREE; TYPE_SIZE (t) = NULL_TREE;
CLASSTYPE_GOT_SEMICOLON (t) = 0;
CLASSTYPE_PRIMARY_BINFO (t) = NULL_TREE; CLASSTYPE_PRIMARY_BINFO (t) = NULL_TREE;
fixup_inline_methods (t); fixup_inline_methods (t);
......
...@@ -1071,12 +1071,12 @@ struct lang_type_class GTY(()) ...@@ -1071,12 +1071,12 @@ struct lang_type_class GTY(())
unsigned has_array_new : 1; unsigned has_array_new : 1;
unsigned gets_delete : 2; unsigned gets_delete : 2;
unsigned has_call_overloaded : 1;
unsigned has_array_ref_overloaded : 1;
unsigned has_arrow_overloaded : 1;
unsigned interface_only : 1; unsigned interface_only : 1;
unsigned interface_unknown : 1; unsigned interface_unknown : 1;
unsigned contains_empty_class_p : 1; unsigned contains_empty_class_p : 1;
unsigned anon_aggr : 1;
unsigned non_zero_init : 1;
unsigned empty_p : 1;
unsigned marks: 6; unsigned marks: 6;
unsigned vec_new_uses_cookie : 1; unsigned vec_new_uses_cookie : 1;
...@@ -1086,7 +1086,7 @@ struct lang_type_class GTY(()) ...@@ -1086,7 +1086,7 @@ struct lang_type_class GTY(())
unsigned redefined : 1; unsigned redefined : 1;
unsigned debug_requested : 1; unsigned debug_requested : 1;
unsigned use_template : 2; unsigned use_template : 2;
unsigned got_semicolon : 1; unsigned fields_readonly : 1;
unsigned ptrmemfunc_flag : 1; unsigned ptrmemfunc_flag : 1;
unsigned was_anonymous : 1; unsigned was_anonymous : 1;
...@@ -1097,11 +1097,6 @@ struct lang_type_class GTY(()) ...@@ -1097,11 +1097,6 @@ struct lang_type_class GTY(())
unsigned has_abstract_assign_ref : 1; unsigned has_abstract_assign_ref : 1;
unsigned non_aggregate : 1; unsigned non_aggregate : 1;
unsigned java_interface : 1; unsigned java_interface : 1;
unsigned anon_aggr : 1;
unsigned non_zero_init : 1;
unsigned empty_p : 1;
unsigned fields_readonly : 1;
/* When adding a flag here, consider whether or not it ought to /* When adding a flag here, consider whether or not it ought to
apply to a template instance if it applies to the template. If apply to a template instance if it applies to the template. If
...@@ -1110,7 +1105,7 @@ struct lang_type_class GTY(()) ...@@ -1110,7 +1105,7 @@ struct lang_type_class GTY(())
/* There are some bits left to fill out a 32-bit word. Keep track /* There are some bits left to fill out a 32-bit word. Keep track
of this by updating the size of this bitfield whenever you add or of this by updating the size of this bitfield whenever you add or
remove a flag. */ remove a flag. */
unsigned dummy : 5; unsigned dummy : 9;
tree primary_base; tree primary_base;
tree vfields; tree vfields;
...@@ -1221,18 +1216,6 @@ struct lang_type GTY(()) ...@@ -1221,18 +1216,6 @@ struct lang_type GTY(())
convenient, don't reprocess any methods that appear in its redefinition. */ convenient, don't reprocess any methods that appear in its redefinition. */
#define TYPE_REDEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->redefined) #define TYPE_REDEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->redefined)
/* Nonzero means that this _CLASSTYPE node overloads operator(). */
#define TYPE_OVERLOADS_CALL_EXPR(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->has_call_overloaded)
/* Nonzero means that this _CLASSTYPE node overloads operator[]. */
#define TYPE_OVERLOADS_ARRAY_REF(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->has_array_ref_overloaded)
/* Nonzero means that this _CLASSTYPE node overloads operator->. */
#define TYPE_OVERLOADS_ARROW(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->has_arrow_overloaded)
/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses /* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses
multiple inheritance. If this is 0 for the root of a type multiple inheritance. If this is 0 for the root of a type
hierarchy, then we can use more efficient search techniques. */ hierarchy, then we can use more efficient search techniques. */
...@@ -1382,9 +1365,6 @@ struct lang_type GTY(()) ...@@ -1382,9 +1365,6 @@ struct lang_type GTY(())
class must provide its own definition for each of these functions. */ class must provide its own definition for each of these functions. */
#define CLASSTYPE_PURE_VIRTUALS(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->pure_virtuals) #define CLASSTYPE_PURE_VIRTUALS(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->pure_virtuals)
/* Nonzero means that this aggr type has been `closed' by a semicolon. */
#define CLASSTYPE_GOT_SEMICOLON(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->got_semicolon)
/* Nonzero means that this type has an X() constructor. */ /* Nonzero means that this type has an X() constructor. */
#define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \ #define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->h.has_default_ctor) (LANG_TYPE_CLASS_CHECK (NODE)->h.has_default_ctor)
...@@ -3763,6 +3743,7 @@ extern tree declare_global_var (tree, tree); ...@@ -3763,6 +3743,7 @@ extern tree declare_global_var (tree, tree);
extern void register_dtor_fn (tree); extern void register_dtor_fn (tree);
extern tmpl_spec_kind current_tmpl_spec_kind (int); extern tmpl_spec_kind current_tmpl_spec_kind (int);
extern tree cp_fname_init (const char *); extern tree cp_fname_init (const char *);
extern tree check_elaborated_type_specifier (enum tag_types, tree, bool);
extern bool have_extern_spec; extern bool have_extern_spec;
/* in decl2.c */ /* in decl2.c */
...@@ -3808,7 +3789,6 @@ extern tree do_class_using_decl (tree); ...@@ -3808,7 +3789,6 @@ extern tree do_class_using_decl (tree);
extern void do_using_directive (tree); extern void do_using_directive (tree);
extern void check_default_args (tree); extern void check_default_args (tree);
extern void mark_used (tree); extern void mark_used (tree);
extern tree handle_class_head (enum tag_types, tree, tree, tree);
extern tree lookup_arg_dependent (tree, tree, tree); extern tree lookup_arg_dependent (tree, tree, tree);
extern void finish_static_data_member_decl (tree, tree, tree, int); extern void finish_static_data_member_decl (tree, tree, tree, int);
extern tree cp_build_parm_decl (tree, tree); extern tree cp_build_parm_decl (tree, tree);
...@@ -3896,8 +3876,6 @@ extern void do_pending_inlines (void); ...@@ -3896,8 +3876,6 @@ extern void do_pending_inlines (void);
extern void yyungetc (int, int); extern void yyungetc (int, int);
extern void snarf_method (tree); extern void snarf_method (tree);
extern void note_got_semicolon (tree);
extern void note_list_got_semicolon (tree);
extern void see_typename (void); extern void see_typename (void);
extern tree unqualified_name_lookup_error (tree); extern tree unqualified_name_lookup_error (tree);
extern tree unqualified_fn_lookup_error (tree); extern tree unqualified_fn_lookup_error (tree);
...@@ -4139,7 +4117,6 @@ extern tree finish_template_type_parm (tree, tree); ...@@ -4139,7 +4117,6 @@ extern tree finish_template_type_parm (tree, tree);
extern tree finish_template_template_parm (tree, tree); extern tree finish_template_template_parm (tree, tree);
extern tree finish_parmlist (tree, int); extern tree finish_parmlist (tree, int);
extern tree begin_class_definition (tree); extern tree begin_class_definition (tree);
extern tree finish_class_definition (tree, tree, int, int);
extern void finish_default_args (void); extern void finish_default_args (void);
extern tree finish_member_class_template (tree); extern tree finish_member_class_template (tree);
extern void finish_template_decl (tree); extern void finish_template_decl (tree);
......
...@@ -8066,7 +8066,6 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags) ...@@ -8066,7 +8066,6 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags)
if (TREE_TYPE (DECL_NAME (decl)) && TREE_TYPE (decl) != type) if (TREE_TYPE (DECL_NAME (decl)) && TREE_TYPE (decl) != type)
warning ("shadowing previous type declaration of `%#D'", decl); warning ("shadowing previous type declaration of `%#D'", decl);
set_identifier_type_value (DECL_NAME (decl), type); set_identifier_type_value (DECL_NAME (decl), type);
CLASSTYPE_GOT_SEMICOLON (type) = 1;
} }
/* If we have installed this as the canonical typedef for this /* If we have installed this as the canonical typedef for this
...@@ -9245,9 +9244,6 @@ build_ptrmemfunc_type (tree type) ...@@ -9245,9 +9244,6 @@ build_ptrmemfunc_type (tree type)
later. */ later. */
TYPE_SET_PTRMEMFUNC_TYPE (type, t); TYPE_SET_PTRMEMFUNC_TYPE (type, t);
/* Seems to be wanted. */
CLASSTYPE_GOT_SEMICOLON (t) = 1;
return t; return t;
} }
...@@ -12241,19 +12237,6 @@ grok_op_properties (tree decl, int friendp) ...@@ -12241,19 +12237,6 @@ grok_op_properties (tree decl, int friendp)
{ {
switch (operator_code) switch (operator_code)
{ {
case CALL_EXPR:
TYPE_OVERLOADS_CALL_EXPR (current_class_type) = 1;
break;
case ARRAY_REF:
TYPE_OVERLOADS_ARRAY_REF (current_class_type) = 1;
break;
case COMPONENT_REF:
case MEMBER_REF:
TYPE_OVERLOADS_ARROW (current_class_type) = 1;
break;
case NEW_EXPR: case NEW_EXPR:
TYPE_HAS_NEW_OPERATOR (current_class_type) = 1; TYPE_HAS_NEW_OPERATOR (current_class_type) = 1;
break; break;
...@@ -12541,7 +12524,7 @@ tag_name (enum tag_types code) ...@@ -12541,7 +12524,7 @@ tag_name (enum tag_types code)
error_mark_node; otherwise, return TYPE itself. error_mark_node; otherwise, return TYPE itself.
If ALLOW_TEMPLATE_P is true, TYPE may be a class template. */ If ALLOW_TEMPLATE_P is true, TYPE may be a class template. */
static tree tree
check_elaborated_type_specifier (enum tag_types tag_code, check_elaborated_type_specifier (enum tag_types tag_code,
tree type, tree type,
bool allow_template_p) bool allow_template_p)
...@@ -12553,8 +12536,8 @@ check_elaborated_type_specifier (enum tag_types tag_code, ...@@ -12553,8 +12536,8 @@ check_elaborated_type_specifier (enum tag_types tag_code,
ill-formed. */ ill-formed. */
if (!t) if (!t)
{ {
error ("using typedef-name `%D' after `%s'", error ("using typedef-name `%T' after `%s'",
TYPE_NAME (type), tag_name (tag_code)); type, tag_name (tag_code));
t = error_mark_node; t = error_mark_node;
} }
else if (TREE_CODE (type) == TEMPLATE_TYPE_PARM) else if (TREE_CODE (type) == TEMPLATE_TYPE_PARM)
...@@ -13412,20 +13395,6 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags) ...@@ -13412,20 +13395,6 @@ start_function (tree declspecs, tree declarator, tree attrs, int flags)
fntype = TREE_TYPE (decl1); fntype = TREE_TYPE (decl1);
restype = TREE_TYPE (fntype); restype = TREE_TYPE (fntype);
if (CLASS_TYPE_P (restype) && !CLASSTYPE_GOT_SEMICOLON (restype))
{
error ("semicolon missing after declaration of `%#T'", restype);
shadow_tag (build_tree_list (NULL_TREE, restype));
CLASSTYPE_GOT_SEMICOLON (restype) = 1;
if (TREE_CODE (fntype) == FUNCTION_TYPE)
fntype = build_function_type (integer_type_node,
TYPE_ARG_TYPES (fntype));
else
fntype = build_cplus_method_type (build_type_variant (TYPE_METHOD_BASETYPE (fntype), TREE_READONLY (decl1), TREE_SIDE_EFFECTS (decl1)),
integer_type_node,
TYPE_ARG_TYPES (fntype));
TREE_TYPE (decl1) = fntype;
}
if (TREE_CODE (fntype) == METHOD_TYPE) if (TREE_CODE (fntype) == METHOD_TYPE)
ctype = TYPE_METHOD_BASETYPE (fntype); ctype = TYPE_METHOD_BASETYPE (fntype);
......
...@@ -223,7 +223,10 @@ tree ...@@ -223,7 +223,10 @@ tree
cp_build_parm_decl (tree name, tree type) cp_build_parm_decl (tree name, tree type)
{ {
tree parm = build_decl (PARM_DECL, name, type); tree parm = build_decl (PARM_DECL, name, type);
DECL_ARG_TYPE (parm) = type_passed_as (type); /* DECL_ARG_TYPE is only used by the back end and the back end never
sees templates. */
if (!processing_template_decl)
DECL_ARG_TYPE (parm) = type_passed_as (type);
return parm; return parm;
} }
...@@ -918,9 +921,6 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree, ...@@ -918,9 +921,6 @@ grokfield (tree declarator, tree declspecs, tree init, tree asmspec_tree,
DECL_NONLOCAL (value) = 1; DECL_NONLOCAL (value) = 1;
DECL_CONTEXT (value) = current_class_type; DECL_CONTEXT (value) = current_class_type;
if (CLASS_TYPE_P (TREE_TYPE (value)))
CLASSTYPE_GOT_SEMICOLON (TREE_TYPE (value)) = 1;
if (processing_template_decl) if (processing_template_decl)
value = push_template_decl (value); value = push_template_decl (value);
...@@ -4215,94 +4215,4 @@ mark_used (tree decl) ...@@ -4215,94 +4215,4 @@ mark_used (tree decl)
} }
} }
/* Called when a class-head is encountered. TAG_KIND is the class-key
for the class. SCOPE, if non-NULL, is the type or namespace
indicated in the nested-name-specifier for the declaration of the
class. ID is the name of the class, if any; it may be a TYPE_DECL,
or an IDENTIFIER_NODE. ATTRIBUTES are attributes that apply to the
class.
Return a TYPE_DECL for the class being defined. */
tree
handle_class_head (enum tag_types tag_kind, tree scope, tree id,
tree attributes)
{
tree decl = NULL_TREE;
tree current = current_scope ();
bool xrefd_p = false;
bool new_type_p;
tree context;
if (current == NULL_TREE)
current = current_namespace;
if (scope)
{
if (TREE_CODE (id) == TYPE_DECL)
/* We must bash typedefs back to the main decl of the
type. Otherwise we become confused about scopes. */
decl = TYPE_MAIN_DECL (TREE_TYPE (id));
else if (DECL_CLASS_TEMPLATE_P (id))
decl = DECL_TEMPLATE_RESULT (id);
else
{
if (TYPE_P (scope))
{
/* According to the suggested resolution of core issue
180, 'typename' is assumed after a class-key. */
decl = make_typename_type (scope, id, tf_error);
if (decl != error_mark_node)
decl = TYPE_MAIN_DECL (decl);
else
decl = NULL_TREE;
}
else if (scope == current)
{
/* We've been given AGGR SCOPE::ID, when we're already
inside SCOPE. Be nice about it. */
if (pedantic)
pedwarn ("extra qualification `%T::' on member `%D' ignored",
scope, id);
}
else
error ("`%T' does not have a class or union named `%D'",
scope, id);
}
}
if (!decl)
{
decl = xref_tag (tag_kind, id, attributes, false, false);
if (decl == error_mark_node)
return error_mark_node;
decl = TYPE_MAIN_DECL (decl);
xrefd_p = true;
}
if (!TYPE_BINFO (TREE_TYPE (decl)))
{
error ("`%T' is not a class or union type", decl);
return error_mark_node;
}
/* For a definition, we want to enter the containing scope before
looking up any base classes etc. Only do so, if this is different
to the current scope. */
context = CP_DECL_CONTEXT (decl);
new_type_p = (current != context
&& TREE_CODE (context) != TEMPLATE_TYPE_PARM
&& TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM);
if (new_type_p)
push_scope (context);
if (!xrefd_p
&& PROCESSING_REAL_TEMPLATE_DECL_P ()
&& !CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl)))
decl = push_template_decl (decl);
return decl;
}
#include "gt-cp-decl2.h" #include "gt-cp-decl2.h"
...@@ -506,28 +506,6 @@ interface_strcmp (const char* s) ...@@ -506,28 +506,6 @@ interface_strcmp (const char* s)
return 1; return 1;
} }
void
note_got_semicolon (tree type)
{
if (!TYPE_P (type))
abort ();
if (CLASS_TYPE_P (type))
CLASSTYPE_GOT_SEMICOLON (type) = 1;
}
void
note_list_got_semicolon (tree declspecs)
{
tree link;
for (link = declspecs; link; link = TREE_CHAIN (link))
{
tree type = TREE_VALUE (link);
if (type && TYPE_P (type))
note_got_semicolon (type);
}
clear_anon_tags ();
}
/* Parse a #pragma whose sole argument is a string constant. /* Parse a #pragma whose sole argument is a string constant.
......
...@@ -100,7 +100,6 @@ static void reopen_tinst_level (tree); ...@@ -100,7 +100,6 @@ static void reopen_tinst_level (tree);
static tree classtype_mangled_name (tree); static tree classtype_mangled_name (tree);
static char* mangle_class_name_for_template (const char *, tree, tree); static char* mangle_class_name_for_template (const char *, tree, tree);
static tree tsubst_initializer_list (tree, tree); static tree tsubst_initializer_list (tree, tree);
static int list_eq (tree, tree);
static tree get_class_bindings (tree, tree, tree); static tree get_class_bindings (tree, tree, tree);
static tree coerce_template_parms (tree, tree, tree, tsubst_flags_t, int); static tree coerce_template_parms (tree, tree, tree, tsubst_flags_t, int);
static void tsubst_enum (tree, tree, tree); static void tsubst_enum (tree, tree, tree);
...@@ -4227,7 +4226,6 @@ lookup_template_class (tree d1, ...@@ -4227,7 +4226,6 @@ lookup_template_class (tree d1,
t = make_aggr_type (TREE_CODE (template_type)); t = make_aggr_type (TREE_CODE (template_type));
CLASSTYPE_DECLARED_CLASS (t) CLASSTYPE_DECLARED_CLASS (t)
= CLASSTYPE_DECLARED_CLASS (template_type); = CLASSTYPE_DECLARED_CLASS (template_type);
CLASSTYPE_GOT_SEMICOLON (t) = 1;
SET_CLASSTYPE_IMPLICIT_INSTANTIATION (t); SET_CLASSTYPE_IMPLICIT_INSTANTIATION (t);
TYPE_FOR_JAVA (t) = TYPE_FOR_JAVA (template_type); TYPE_FOR_JAVA (t) = TYPE_FOR_JAVA (template_type);
...@@ -5141,9 +5139,6 @@ instantiate_class_template (tree type) ...@@ -5141,9 +5139,6 @@ instantiate_class_template (tree type)
TYPE_HAS_CONSTRUCTOR (type) = TYPE_HAS_CONSTRUCTOR (pattern); TYPE_HAS_CONSTRUCTOR (type) = TYPE_HAS_CONSTRUCTOR (pattern);
TYPE_HAS_DESTRUCTOR (type) = TYPE_HAS_DESTRUCTOR (pattern); TYPE_HAS_DESTRUCTOR (type) = TYPE_HAS_DESTRUCTOR (pattern);
TYPE_OVERLOADS_CALL_EXPR (type) = TYPE_OVERLOADS_CALL_EXPR (pattern);
TYPE_OVERLOADS_ARRAY_REF (type) = TYPE_OVERLOADS_ARRAY_REF (pattern);
TYPE_OVERLOADS_ARROW (type) = TYPE_OVERLOADS_ARROW (pattern);
TYPE_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern); TYPE_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern);
TYPE_HAS_ARRAY_NEW_OPERATOR (type) = TYPE_HAS_ARRAY_NEW_OPERATOR (pattern); TYPE_HAS_ARRAY_NEW_OPERATOR (type) = TYPE_HAS_ARRAY_NEW_OPERATOR (pattern);
TYPE_GETS_DELETE (type) = TYPE_GETS_DELETE (pattern); TYPE_GETS_DELETE (type) = TYPE_GETS_DELETE (pattern);
...@@ -5385,7 +5380,6 @@ instantiate_class_template (tree type) ...@@ -5385,7 +5380,6 @@ instantiate_class_template (tree type)
unreverse_member_declarations (type); unreverse_member_declarations (type);
finish_struct_1 (type); finish_struct_1 (type);
CLASSTYPE_GOT_SEMICOLON (type) = 1;
/* Clear this now so repo_template_used is happy. */ /* Clear this now so repo_template_used is happy. */
TYPE_BEING_DEFINED (type) = 0; TYPE_BEING_DEFINED (type) = 0;
...@@ -5414,21 +5408,6 @@ instantiate_class_template (tree type) ...@@ -5414,21 +5408,6 @@ instantiate_class_template (tree type)
return type; return type;
} }
static int
list_eq (tree t1, tree t2)
{
if (t1 == NULL_TREE)
return t2 == NULL_TREE;
if (t2 == NULL_TREE)
return 0;
/* Don't care if one declares its arg const and the other doesn't -- the
main variant of the arg type is all that matters. */
if (TYPE_MAIN_VARIANT (TREE_VALUE (t1))
!= TYPE_MAIN_VARIANT (TREE_VALUE (t2)))
return 0;
return list_eq (TREE_CHAIN (t1), TREE_CHAIN (t2));
}
static tree static tree
tsubst_template_arg (tree t, tree args, tsubst_flags_t complain, tree in_decl) tsubst_template_arg (tree t, tree args, tsubst_flags_t complain, tree in_decl)
{ {
...@@ -6020,11 +5999,14 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain) ...@@ -6020,11 +5999,14 @@ tsubst_decl (tree t, tree args, tree type, tsubst_flags_t complain)
TREE_TYPE (r) = type; TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (cp_type_quals (type), r); c_apply_type_quals_to_decl (cp_type_quals (type), r);
if (TREE_CODE (DECL_INITIAL (r)) != TEMPLATE_PARM_INDEX) if (DECL_INITIAL (r))
DECL_INITIAL (r) = TREE_TYPE (r); {
else if (TREE_CODE (DECL_INITIAL (r)) != TEMPLATE_PARM_INDEX)
DECL_INITIAL (r) = tsubst (DECL_INITIAL (r), args, DECL_INITIAL (r) = TREE_TYPE (r);
complain, in_decl); else
DECL_INITIAL (r) = tsubst (DECL_INITIAL (r), args,
complain, in_decl);
}
DECL_CONTEXT (r) = NULL_TREE; DECL_CONTEXT (r) = NULL_TREE;
......
...@@ -123,12 +123,6 @@ cxx_print_type (FILE *file, tree node, int indent) ...@@ -123,12 +123,6 @@ cxx_print_type (FILE *file, tree node, int indent)
fputs (" delete[]", file); fputs (" delete[]", file);
if (TYPE_HAS_ASSIGN_REF (node)) if (TYPE_HAS_ASSIGN_REF (node))
fputs (" this=(X&)", file); fputs (" this=(X&)", file);
if (TYPE_OVERLOADS_CALL_EXPR (node))
fputs (" op()", file);
if (TYPE_OVERLOADS_ARRAY_REF (node))
fputs (" op[]", file);
if (TYPE_OVERLOADS_ARROW (node))
fputs (" op->", file);
if (TYPE_USES_MULTIPLE_INHERITANCE (node)) if (TYPE_USES_MULTIPLE_INHERITANCE (node))
fputs (" uses-multiple-inheritance", file); fputs (" uses-multiple-inheritance", file);
......
...@@ -2133,41 +2133,6 @@ finish_member_declaration (tree decl) ...@@ -2133,41 +2133,6 @@ finish_member_declaration (tree decl)
} }
} }
/* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
the definition is immediately followed by a semicolon. Returns the
type. */
tree
finish_class_definition (tree t, tree attributes, int semi, int pop_scope_p)
{
if (t == error_mark_node)
return error_mark_node;
/* finish_struct nukes this anyway; if finish_exception does too,
then it can go. */
if (semi)
note_got_semicolon (t);
/* If we got any attributes in class_head, xref_tag will stick them in
TREE_TYPE of the type. Grab them now. */
attributes = chainon (TYPE_ATTRIBUTES (t), attributes);
TYPE_ATTRIBUTES (t) = NULL_TREE;
if (TREE_CODE (t) == ENUMERAL_TYPE)
;
else
{
t = finish_struct (t, attributes);
if (semi)
note_got_semicolon (t);
}
if (pop_scope_p)
pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
return t;
}
/* Finish processing the declaration of a member class template /* Finish processing the declaration of a member class template
TYPES whose template parameters are given by PARMS. */ TYPES whose template parameters are given by PARMS. */
...@@ -2183,7 +2148,6 @@ finish_member_class_template (tree types) ...@@ -2183,7 +2148,6 @@ finish_member_class_template (tree types)
if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t)))) if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
maybe_process_partial_specialization (TREE_VALUE (t)); maybe_process_partial_specialization (TREE_VALUE (t));
note_list_got_semicolon (types);
grok_x_components (types); grok_x_components (types);
if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type) if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
/* The component was in fact a friend declaration. We avoid /* The component was in fact a friend declaration. We avoid
......
2003-08-12 Mark Mitchell <mark@codesourcery.com>
* g++.dg/parse/ret-type2.C: New test.
PR c++/11703
* g++.dg/init/new8.C: New test.
PR c++/10923
* g++.dg/parse/typedef5.C: New test.
PR c++/9512
* g++.dg/parse/qualified2.C: New test.
* g++.old-deja/g++.other/decl5.C: Mark one more instance of
invalid code.
2003-08-11 Mark Mitchell <mark@codesourcery.com> 2003-08-11 Mark Mitchell <mark@codesourcery.com>
* g++.dg/conversion/ptrmem1.C: New test. * g++.dg/conversion/ptrmem1.C: New test.
......
typedef unsigned int size_t;
enum Refcount_Type {
NO_REFCOUNT
};
struct d0_Unknown_Object
{
void* operator new (size_t, size_t, Refcount_Type type);
void operator delete (void*, size_t, Refcount_Type);
d0_Unknown_Object ();
};
void make ()
{
new (10, NO_REFCOUNT) d0_Unknown_Object;
}
namespace Glib {
template <typename> class Value {};
template <> class Glib::Value<int> {}; // { dg-error "" }
}
struct S {} f(); // { dg-error "" }
struct T {} *g(); // { dg-error "" }
struct U {} h() {} // { dg-error "" }
struct V {} *i() {} // { dg-error "" }
struct W {} (*p) (); // { dg-error "" }
namespace A
{
typedef int T;
}
class A::T x; // { dg-error "" }
...@@ -11,7 +11,7 @@ struct A { ...@@ -11,7 +11,7 @@ struct A {
int A::fn(); // { dg-warning "" } extra qualification int A::fn(); // { dg-warning "" } extra qualification
int A::m; // { dg-warning "" } extra qualification int A::m; // { dg-warning "" } extra qualification
struct e; struct e;
struct A::e {int i;}; struct A::e {int i;}; // { dg-warning "" } extra qualification
struct A::expand { // { dg-warning "" } extra qualification struct A::expand { // { dg-warning "" } extra qualification
int m; int m;
}; };
......
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