cp-tree.h (constructor_name_p): Declare it.

* cp-tree.h (constructor_name_p): Declare it.
	(check_template_template_default_arg): Likewise.
	* class.c (handle_using_decl): Use constructor_name_p.
	* decl.c (grokdeclarator): Likewise.
	* decl2.c (constructor_name_p): Define it.
	* init.c (build_member_call): Use constructor_name_p.
	* parse.y (template_parm): Use check_template_template_default_arg.
	* pt.c (check_explicit_specialization): Use constructor_name_p.
	* semantics.c (check_template_template_default_arg): New function.

From-SVN: r55350
This commit is contained in:
Mark Mitchell 2002-07-09 23:31:28 +00:00 committed by Mark Mitchell
parent 2fefbb5dbc
commit 8ba658eea5
9 changed files with 54 additions and 27 deletions

View File

@ -1,3 +1,15 @@
2002-07-09 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (constructor_name_p): Declare it.
(check_template_template_default_arg): Likewise.
* class.c (handle_using_decl): Use constructor_name_p.
* decl.c (grokdeclarator): Likewise.
* decl2.c (constructor_name_p): Define it.
* init.c (build_member_call): Use constructor_name_p.
* parse.y (template_parm): Use check_template_template_default_arg.
* pt.c (check_explicit_specialization): Use constructor_name_p.
* semantics.c (check_template_template_default_arg): New function.
2002-07-08 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> 2002-07-08 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* pt.c (can_complete_type_without_circularity): Add static to * pt.c (can_complete_type_without_circularity): Add static to

View File

@ -1212,14 +1212,12 @@ handle_using_decl (using_decl, t)
if (! binfo) if (! binfo)
return; return;
if (name == constructor_name (ctype) if (constructor_name_p (name, ctype))
|| name == constructor_name_full (ctype))
{ {
cp_error_at ("`%D' names constructor", using_decl); cp_error_at ("`%D' names constructor", using_decl);
return; return;
} }
if (name == constructor_name (t) if (constructor_name_p (name, t))
|| name == constructor_name_full (t))
{ {
cp_error_at ("`%D' invalid in `%T'", using_decl, t); cp_error_at ("`%D' invalid in `%T'", using_decl, t);
return; return;

View File

@ -3926,6 +3926,7 @@ extern tree grokoptypename PARAMS ((tree, tree));
extern void cplus_decl_attributes PARAMS ((tree *, tree, int)); extern void cplus_decl_attributes PARAMS ((tree *, tree, int));
extern tree constructor_name_full PARAMS ((tree)); extern tree constructor_name_full PARAMS ((tree));
extern tree constructor_name PARAMS ((tree)); extern tree constructor_name PARAMS ((tree));
extern bool constructor_name_p (tree, tree);
extern void defer_fn PARAMS ((tree)); extern void defer_fn PARAMS ((tree));
extern void finish_anon_union PARAMS ((tree)); extern void finish_anon_union PARAMS ((tree));
extern tree finish_table PARAMS ((tree, tree, tree, int)); extern tree finish_table PARAMS ((tree, tree, tree, int));
@ -4318,7 +4319,7 @@ extern void setup_vtbl_ptr PARAMS ((tree, tree));
extern void clear_out_block PARAMS ((void)); extern void clear_out_block PARAMS ((void));
extern tree begin_global_stmt_expr PARAMS ((void)); extern tree begin_global_stmt_expr PARAMS ((void));
extern tree finish_global_stmt_expr PARAMS ((tree)); extern tree finish_global_stmt_expr PARAMS ((tree));
extern tree check_template_template_default_arg (tree);
/* in spew.c */ /* in spew.c */
extern void init_spew PARAMS ((void)); extern void init_spew PARAMS ((void));

View File

@ -9848,10 +9848,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (ctype if (ctype
&& TREE_OPERAND (decl, 0) && TREE_OPERAND (decl, 0)
&& (TREE_CODE (TREE_OPERAND (decl, 0)) == TYPE_DECL && (TREE_CODE (TREE_OPERAND (decl, 0)) == TYPE_DECL
&& ((DECL_NAME (TREE_OPERAND (decl, 0)) && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 0)),
== constructor_name_full (ctype)) ctype)))
|| (DECL_NAME (TREE_OPERAND (decl, 0))
== constructor_name (ctype)))))
TREE_OPERAND (decl, 0) = constructor_name (ctype); TREE_OPERAND (decl, 0) = constructor_name (ctype);
next = &TREE_OPERAND (decl, 0); next = &TREE_OPERAND (decl, 0);
decl = *next; decl = *next;
@ -9958,10 +9956,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
} }
if (ctype && TREE_CODE (TREE_OPERAND (decl, 1)) == TYPE_DECL if (ctype && TREE_CODE (TREE_OPERAND (decl, 1)) == TYPE_DECL
&& ((DECL_NAME (TREE_OPERAND (decl, 1)) && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 1)),
== constructor_name_full (ctype)) ctype))
|| (DECL_NAME (TREE_OPERAND (decl, 1))
== constructor_name (ctype))))
TREE_OPERAND (decl, 1) = constructor_name (ctype); TREE_OPERAND (decl, 1) = constructor_name (ctype);
next = &TREE_OPERAND (decl, 1); next = &TREE_OPERAND (decl, 1);
decl = *next; decl = *next;
@ -9975,8 +9971,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
} }
else if (TREE_CODE (decl) == BIT_NOT_EXPR else if (TREE_CODE (decl) == BIT_NOT_EXPR
&& TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
&& (constructor_name (ctype) == TREE_OPERAND (decl, 0) && constructor_name_p (TREE_OPERAND (decl, 0),
|| constructor_name_full (ctype) == TREE_OPERAND (decl, 0))) ctype))
{ {
sfk = sfk_destructor; sfk = sfk_destructor;
ctor_return_type = ctype; ctor_return_type = ctype;

View File

@ -1810,6 +1810,16 @@ constructor_name (thing)
return thing; return thing;
return t; return t;
} }
/* Returns TRUE if NAME is the name for the constructor for TYPE. */
bool
constructor_name_p (tree name, tree type)
{
return (name == constructor_name (type)
|| name == constructor_name_full (type));
}
/* Defer the compilation of the FN until the end of compilation. */ /* Defer the compilation of the FN until the end of compilation. */

View File

@ -1522,8 +1522,7 @@ build_member_call (type, name, parmlist)
return error_mark_node; return error_mark_node;
} }
if (method_name == constructor_name (type) if (constructor_name_p (method_name, type))
|| method_name == constructor_name_full (type))
return build_functional_cast (type, parmlist); return build_functional_cast (type, parmlist);
if (lookup_fnfields (basetype_path, method_name, 0)) if (lookup_fnfields (basetype_path, method_name, 0))
return build_method_call (decl, return build_method_call (decl,

View File

@ -710,14 +710,7 @@ template_parm:
{ $$ = build_tree_list (NULL_TREE, $1); } { $$ = build_tree_list (NULL_TREE, $1); }
| template_template_parm '=' template_arg | template_template_parm '=' template_arg
{ {
if (TREE_CODE ($3) != TEMPLATE_DECL $3 = check_template_template_default_arg ($3);
&& TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
&& TREE_CODE ($3) != TYPE_DECL
&& TREE_CODE ($3) != UNBOUND_CLASS_TEMPLATE)
{
error ("invalid default template argument");
$3 = error_mark_node;
}
$$ = build_tree_list ($3, $1); $$ = build_tree_list ($3, $1);
} }
; ;

View File

@ -1529,8 +1529,7 @@ check_explicit_specialization (declarator, decl, template_count, flags)
tree fns = NULL_TREE; tree fns = NULL_TREE;
int idx; int idx;
if (name == constructor_name (ctype) if (constructor_name_p (name, ctype))
|| name == constructor_name_full (ctype))
{ {
int is_constructor = DECL_CONSTRUCTOR_P (decl); int is_constructor = DECL_CONSTRUCTOR_P (decl);

View File

@ -1625,6 +1625,25 @@ finish_template_template_parm (aggr, identifier)
return finish_template_type_parm (aggr, tmpl); return finish_template_type_parm (aggr, tmpl);
} }
/* ARGUMENT is the default-argument value for a template template
parameter. If ARGUMENT is invalid, issue error messages and return
the ERROR_MARK_NODE. Otherwise, ARGUMENT itself is returned. */
tree
check_template_template_default_arg (tree argument)
{
if (TREE_CODE (argument) != TEMPLATE_DECL
&& TREE_CODE (argument) != TEMPLATE_TEMPLATE_PARM
&& TREE_CODE (argument) != TYPE_DECL
&& TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
{
error ("invalid default template argument");
return error_mark_node;
}
return argument;
}
/* Finish a parameter list, indicated by PARMS. If ELLIPSIS is /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
non-zero, the parameter list was terminated by a `...'. */ non-zero, the parameter list was terminated by a `...'. */