* tree.c (is_overloaded_fn): Handle getting a fn template.
(really_overloaded_fn): Likewise.
* error.c (dump_decl): Handle TEMPLATE_ID_EXPRs better.
* pt.c (check_explicit_specialization): Tweak.
(determine_explicit_specialization): Tweak.
* tree.c, cp-tree.h (get_target_expr): New fn.
1997-12-02 Mark Mitchell <mmitchell@usa.net>
* pt.c (determine_explicit_specialization): Avoid an internal
error for bad specializations.
* method.c (build_overload_value): Handle SCOPE_REF.
From-SVN: r16928
+Wed Dec 3 11:44:52 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * tree.c (is_overloaded_fn): Handle getting a fn template.
+ (really_overloaded_fn): Likewise.
+ * error.c (dump_decl): Handle TEMPLATE_ID_EXPRs better.
+ * pt.c (check_explicit_specialization): Tweak.
+ (determine_explicit_specialization): Tweak.
+
+ * tree.c, cp-tree.h (get_target_expr): New fn.
+
+1997-12-02 Mark Mitchell <mmitchell@usa.net>
+
+ * pt.c (determine_explicit_specialization): Avoid an internal
+ error for bad specializations.
+
+ * method.c (build_overload_value): Handle SCOPE_REF.
+
Tue Dec 2 19:18:50 1997 Mike Stump <mrs@wrs.com>
* class.c (prepare_fresh_vtable): Enable even more complex MI
extern int lvalue_p PROTO((tree));
extern int lvalue_or_else PROTO((tree, char *));
extern tree build_cplus_new PROTO((tree, tree));
+extern tree get_target_expr PROTO((tree));
extern tree break_out_cleanups PROTO((tree));
extern tree break_out_calls PROTO((tree));
extern tree build_cplus_method_type PROTO((tree, tree, tree));
case TEMPLATE_ID_EXPR:
{
tree args;
- dump_type (TREE_OPERAND (t, 0), v);
+ tree name = TREE_OPERAND (t, 0);
+ if (is_overloaded_fn (name))
+ name = DECL_NAME (get_first_fn (name));
+ dump_decl (name, v);
OB_PUTC ('<');
for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args))
{
build_overload_identifier (DECL_ASSEMBLER_NAME (value));
return;
}
+ else if (TREE_CODE (value) == SCOPE_REF)
+ {
+ OB_PUTC2 ('Q', '1');
+ numeric_output_need_bar = 0;
+ build_overload_name (TREE_OPERAND (value, 0), 0, 0);
+ build_overload_identifier (TREE_OPERAND (value, 1));
+ return;
+ }
else
my_friendly_abort (71);
break; /* not really needed */
int overloaded;
tree fns;
tree matching_fns = NULL_TREE;
- tree name = NULL_TREE;
tree result;
tree fn;
- my_friendly_assert (TREE_CODE (template_id) == TEMPLATE_ID_EXPR,
- 0);
+ my_friendly_assert (TREE_CODE (template_id) == TEMPLATE_ID_EXPR
+ && TREE_OPERAND (template_id, 0), 0);
fns = TREE_OPERAND (template_id, 0);
- overloaded = fns != NULL_TREE && really_overloaded_fn (fns);
+ if (is_overloaded_fn (fns))
+ fn = get_first_fn (fns);
+ else
+ fn = NULL_TREE;
+
+ overloaded = really_overloaded_fn (fns);
- for (fn = (fns != NULL_TREE) ? get_first_fn (fns) : NULL_TREE;
- fn != NULL_TREE;
+ for (; fn != NULL_TREE;
fn = overloaded ? DECL_CHAIN (fn) : NULL_TREE)
{
int dummy = 0;
tree targs;
- if (name == NULL_TREE)
- name = DECL_NAME (fn);
-
if (TREE_CODE (fn) != TEMPLATE_DECL
|| (need_member_template && !is_member_template (fn)))
continue;
if (matching_fns == NULL_TREE)
{
if (complain)
- cp_error ("Specialization of `%s' does not match any template declaration.",
- IDENTIFIER_POINTER (name));
+ cp_error ("`%D' does not match any template declaration.",
+ template_id);
+
*targs_out = NULL_TREE;
return NULL_TREE;
}
&& !processing_explicit_specialization (template_count)
&& !is_friend)
{
- if (!have_def && ! template_header_count)
- /* This is not an explicit specialization. It must be
+ if (! have_def && ! template_header_count && ! ctype)
+ /* This is not an explict specialization. It must be
an explicit instantiation. */
return 2;
else if (template_header_count > template_count
declarator);
return 0;
}
- else if (pedantic)
+ else if (pedantic || uses_template_parms (decl))
pedwarn ("explicit specialization not preceeded by `template <>'");
}
return init;
slot = build (VAR_DECL, type);
+ DECL_ARTIFICIAL (slot) = 1;
layout_decl (slot, 0);
rval = build (NEW_EXPR, type,
TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), slot);
return rval;
}
+/* Encapsulate the expression INIT in a TARGET_EXPR. */
+
+tree
+get_target_expr (init)
+ tree init;
+{
+ tree slot;
+ tree rval;
+
+ slot = build (VAR_DECL, TREE_TYPE (init));
+ DECL_ARTIFICIAL (slot) = 1;
+ layout_decl (slot, 0);
+ rval = build (TARGET_EXPR, TREE_TYPE (init), slot, init,
+ NULL_TREE, NULL_TREE);
+ TREE_SIDE_EFFECTS (rval) = 1;
+
+ return rval;
+}
+
/* Recursively search EXP for CALL_EXPRs that need cleanups and replace
these CALL_EXPRs with tree nodes that will perform the cleanups. */
is_overloaded_fn (x)
tree x;
{
- if (TREE_CODE (x) == FUNCTION_DECL)
- return 1;
-
- if (TREE_CODE (x) == TEMPLATE_ID_EXPR)
+ if (TREE_CODE (x) == FUNCTION_DECL
+ || TREE_CODE (x) == TEMPLATE_ID_EXPR
+ || DECL_FUNCTION_TEMPLATE_P (x))
return 1;
if (TREE_CODE (x) == TREE_LIST
&& (TREE_CODE (TREE_VALUE (x)) == FUNCTION_DECL
- || TREE_CODE (TREE_VALUE (x)) == TEMPLATE_DECL))
+ || DECL_FUNCTION_TEMPLATE_P (TREE_VALUE (x))))
return 1;
return 0;
really_overloaded_fn (x)
tree x;
{
- if (TREE_CODE (x) == TEMPLATE_ID_EXPR)
+ if (TREE_CODE (x) == TEMPLATE_ID_EXPR
+ || DECL_FUNCTION_TEMPLATE_P (x))
return 1;
if (TREE_CODE (x) == TREE_LIST