From 69f547cf1824c1fd2cee5cdaf9f1952173b2a2be Mon Sep 17 00:00:00 2001 From: mmitchel Date: Thu, 7 Oct 1999 16:41:48 +0000 Subject: [PATCH] * friend.c (make_friend_class): Robustify. * semantics.c (finish_object_call_expr): Reject calls to template types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29855 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/friend.c | 15 ++++++++++++--- gcc/cp/semantics.c | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0a64b4d4f26..526edb1541c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +1999-10-07 Mark Mitchell + + * friend.c (make_friend_class): Robustify. + + * semantics.c (finish_object_call_expr): Reject calls to template + types. + 1999-10-06 Mark Mitchell * dump.c (dequeue_and_dump): Dump all three operands to a COND_EXPR. diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c index 410eaf5c82b..d2325f34c15 100644 --- a/gcc/cp/friend.c +++ b/gcc/cp/friend.c @@ -277,7 +277,8 @@ make_friend_class (type, friend_type) is_template_friend = 0; if (is_template_friend - && TREE_CODE (friend_type) == TYPENAME_TYPE) + && (TREE_CODE (friend_type) == TYPENAME_TYPE + || TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM)) { /* [temp.friend] @@ -290,9 +291,17 @@ make_friend_class (type, friend_type) template friend typename S::X; + or: + + template friend class T; + which isn't any of these. */ - cp_error ("typename type `%T' declared `friend'", - friend_type); + if (TREE_CODE (friend_type) == TYPENAME_TYPE) + cp_error ("typename type `%T' declared `friend'", + friend_type); + else + cp_error ("template parameter type `%T' declared `friend'", + friend_type); return; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index eb94da0f6e8..da17d3b3a01 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1480,7 +1480,7 @@ finish_object_call_expr (fn, object, args) tree real_fn = build_component_ref (object, fn, NULL_TREE, 1); return finish_call_expr (real_fn, args); #else - if (TREE_CODE (fn) == TYPE_DECL) + if (DECL_DECLARES_TYPE_P (fn)) { if (processing_template_decl) /* This can happen on code like: -- 2.11.4.GIT