* 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
+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>
* pt.c (can_complete_type_without_circularity): Add static to
if (! binfo)
return;
- if (name == constructor_name (ctype)
- || name == constructor_name_full (ctype))
+ if (constructor_name_p (name, ctype))
{
cp_error_at ("`%D' names constructor", using_decl);
return;
}
- if (name == constructor_name (t)
- || name == constructor_name_full (t))
+ if (constructor_name_p (name, t))
{
cp_error_at ("`%D' invalid in `%T'", using_decl, t);
return;
extern void cplus_decl_attributes PARAMS ((tree *, tree, int));
extern tree constructor_name_full PARAMS ((tree));
extern tree constructor_name PARAMS ((tree));
+extern bool constructor_name_p (tree, tree);
extern void defer_fn PARAMS ((tree));
extern void finish_anon_union PARAMS ((tree));
extern tree finish_table PARAMS ((tree, tree, tree, int));
extern void clear_out_block PARAMS ((void));
extern tree begin_global_stmt_expr PARAMS ((void));
extern tree finish_global_stmt_expr PARAMS ((tree));
-
+extern tree check_template_template_default_arg (tree);
/* in spew.c */
extern void init_spew PARAMS ((void));
if (ctype
&& TREE_OPERAND (decl, 0)
&& (TREE_CODE (TREE_OPERAND (decl, 0)) == TYPE_DECL
- && ((DECL_NAME (TREE_OPERAND (decl, 0))
- == constructor_name_full (ctype))
- || (DECL_NAME (TREE_OPERAND (decl, 0))
- == constructor_name (ctype)))))
+ && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 0)),
+ ctype)))
TREE_OPERAND (decl, 0) = constructor_name (ctype);
next = &TREE_OPERAND (decl, 0);
decl = *next;
}
if (ctype && TREE_CODE (TREE_OPERAND (decl, 1)) == TYPE_DECL
- && ((DECL_NAME (TREE_OPERAND (decl, 1))
- == constructor_name_full (ctype))
- || (DECL_NAME (TREE_OPERAND (decl, 1))
- == constructor_name (ctype))))
+ && constructor_name_p (DECL_NAME (TREE_OPERAND (decl, 1)),
+ ctype))
TREE_OPERAND (decl, 1) = constructor_name (ctype);
next = &TREE_OPERAND (decl, 1);
decl = *next;
}
else if (TREE_CODE (decl) == BIT_NOT_EXPR
&& TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
- && (constructor_name (ctype) == TREE_OPERAND (decl, 0)
- || constructor_name_full (ctype) == TREE_OPERAND (decl, 0)))
+ && constructor_name_p (TREE_OPERAND (decl, 0),
+ ctype))
{
sfk = sfk_destructor;
ctor_return_type = ctype;
return thing;
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));
+}
+
\f
/* Defer the compilation of the FN until the end of compilation. */
return error_mark_node;
}
- if (method_name == constructor_name (type)
- || method_name == constructor_name_full (type))
+ if (constructor_name_p (method_name, type))
return build_functional_cast (type, parmlist);
if (lookup_fnfields (basetype_path, method_name, 0))
return build_method_call (decl,
{ $$ = build_tree_list (NULL_TREE, $1); }
| template_template_parm '=' template_arg
{
- if (TREE_CODE ($3) != TEMPLATE_DECL
- && 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;
- }
+ $3 = check_template_template_default_arg ($3);
$$ = build_tree_list ($3, $1);
}
;
tree fns = NULL_TREE;
int idx;
- if (name == constructor_name (ctype)
- || name == constructor_name_full (ctype))
+ if (constructor_name_p (name, ctype))
{
int is_constructor = DECL_CONSTRUCTOR_P (decl);
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
non-zero, the parameter list was terminated by a `...'. */