1999-04-11 Mark Mitchell <mark@codesourcery.com>
+ * friend.c (add_friend): Deal gracefully with error_mark_node.
+ * method.c (build_overload_value): Handle pointers-to-members as
+ template parameters.
+
* decl.c (push_binding): Fix typo in comment.
1999-04-10 Mark Mitchell <mark@codesourcery.com>
add_friend (type, decl)
tree type, decl;
{
- tree typedecl = TYPE_MAIN_DECL (type);
- tree list = DECL_FRIENDLIST (typedecl);
- tree name = DECL_NAME (decl);
+ tree typedecl;
+ tree list;
+ tree name;
+
+ if (decl == error_mark_node)
+ return;
+ typedecl = TYPE_MAIN_DECL (type);
+ list = DECL_FRIENDLIST (typedecl);
+ name = DECL_NAME (decl);
type = TREE_TYPE (typedecl);
while (list)
tree delta2;
my_friendly_assert (TYPE_PTRMEMFUNC_P (type), 0);
+
+ /* We'll get a ADDR_EXPR of a SCOPE_REF here if we're
+ mangling, an instantiation of something like:
+
+ template <class T, void (T::*fp)()> class C {};
+ template <class T> C<T, &T::f> x();
+
+ We mangle the return type of the function, and that
+ contains template parameters. */
+ if (TREE_CODE (value) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (value, 0)) == SCOPE_REF)
+ {
+ build_overload_scope_ref (TREE_OPERAND (value, 0));
+ break;
+ }
+
my_friendly_assert (TREE_CODE (value) == PTRMEM_CST, 0);
expand_ptrmemfunc_cst (value, &delta, &idx, &pfn, &delta2);
--- /dev/null
+// Build don't link:
+// Origin: Jens Maurer <jmaurer@menuett.rhein-main.de>
+
+template<class T, void (T::*f)(int)>
+class C { };
+
+template<class T>
+C<T, &T::output> call(T& obj)
+{ return C<T, &T::output>();
+}
+
+class Test {
+public:
+ void output(int);
+};
+
+void sub()
+{
+ Test t;
+ call(t);
+}
+