2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/5123
+ * typeck.c (build_component_ref): Cope with a TEMPLATE_ID_EXPR.
+ (build_x_function_call): Cope with a COMPONENT_REF containing a
+ TEMPLATE_ID_EXPR.
+
+2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+
PR c++/5213
* pt.c (convert_template_argument): Be more careful determining
when RECORD_TYPE templates are or are not templates.
basetype_path, protect));
case TEMPLATE_DECL:
- error ("invalid use of %D", datum);
+ error ("invalid use of `%D'", datum);
datum = error_mark_node;
break;
else
{
tree name = component;
- if (TREE_CODE (component) == VAR_DECL)
+
+ if (TREE_CODE (component) == TEMPLATE_ID_EXPR)
+ name = TREE_OPERAND (component, 0);
+ else if (TREE_CODE (component) == VAR_DECL)
name = DECL_NAME (component);
if (TREE_CODE (component) == NAMESPACE_DECL)
/* Source is in error, but produce a sensible diagnostic. */
}
}
+ fndecls = TREE_VALUE (fndecls);
+
+ if (TREE_CODE (component) == TEMPLATE_ID_EXPR)
+ fndecls = build_nt (TEMPLATE_ID_EXPR,
+ fndecls, TREE_OPERAND (component, 1));
+
ref = build (COMPONENT_REF, unknown_type_node,
- datum, TREE_VALUE (fndecls));
+ datum, fndecls);
return ref;
}
/* Undo what we did in build_component_ref. */
decl = TREE_OPERAND (function, 0);
function = TREE_OPERAND (function, 1);
- function = DECL_NAME (OVL_CURRENT (function));
- if (template_id)
+ if (TREE_CODE (function) == TEMPLATE_ID_EXPR)
+ {
+ my_friendly_assert (!template_id, 20011228);
+
+ template_id = function;
+ }
+ else
{
- TREE_OPERAND (template_id, 0) = function;
- function = template_id;
+ function = DECL_NAME (OVL_CURRENT (function));
+
+ if (template_id)
+ {
+ TREE_OPERAND (template_id, 0) = function;
+ function = template_id;
+ }
}
return build_method_call (decl, function, params,
--- /dev/null
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 28 Dec 2001 <nathan@codesourcery.com>
+
+// PR 5123. ICE
+
+struct C {
+ template<class T> void f(T);
+ void g ();
+ void g (int);
+};
+
+void Foo () {
+ C c;
+
+ (c.g) ();
+ (c.f) (1);
+
+ (c.f<int>) (2);
+
+ c.g; // { dg-error "statement cannot resolve" "" }
+ c.f; // { dg-error "statement cannot resolve" "" }
+ c.f<int>; // { dg-error "statement cannot resolve" "" }
+
+ c.g == 1; // { dg-error "invalid use of" "" }
+ c.f == 1; // { dg-error "invalid use of" "" }
+ c.f<int> == 1; // { dg-error "invalid use of" "" }
+};