From 248e1b22b25685386d34956368cb80c707a22a2f Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 10 Dec 2008 01:23:28 +0000 Subject: re PR c++/37971 (Rejects default argument that is a template via access failure) PR c++/37971 * class.c (resolve_address_of_overloaded_function): Check accessibility of member functions unless FLAGS indicates otherwise. * call.c (standard_conversion): Adjust flags passed to instantiate_type. (convert_default_arg): Do not perform access checks. * cp-tree.h (tsubst_flags_t): Add tf_no_access_control. PR c++/37971 * g++.dg/overload/defarg2.C: New test. * g++.dg/overload/defarg3.C: Likewise. From-SVN: r142628 --- gcc/cp/class.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 97ab9e3..805e513 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5923,9 +5923,13 @@ pop_lang_context (void) control of FLAGS. Permit pointers to member function if FLAGS permits. If TEMPLATE_ONLY, the name of the overloaded function was a template-id, and EXPLICIT_TARGS are the explicitly provided - template arguments. If OVERLOAD is for one or more member - functions, then ACCESS_PATH is the base path used to reference - those member functions. */ + template arguments. + + If OVERLOAD is for one or more member functions, then ACCESS_PATH + is the base path used to reference those member functions. If + TF_NO_ACCESS_CONTROL is not set in FLAGS, and the address is + resolved to a member function, access checks will be performed and + errors issued if appropriate. */ static tree resolve_address_of_overloaded_function (tree target_type, @@ -6190,14 +6194,16 @@ resolve_address_of_overloaded_function (tree target_type, return error_mark_node; mark_used (fn); - /* We could not check access when this expression was originally - created since we did not know at that time to which function - the expression referred. */ - if (DECL_FUNCTION_MEMBER_P (fn)) - { - gcc_assert (access_path); - perform_or_defer_access_check (access_path, fn, fn); - } + } + + /* We could not check access to member functions when this + expression was originally created since we did not know at that + time to which function the expression referred. */ + if (!(flags & tf_no_access_control) + && DECL_FUNCTION_MEMBER_P (fn)) + { + gcc_assert (access_path); + perform_or_defer_access_check (access_path, fn, fn); } if (TYPE_PTRFN_P (target_type) || TYPE_PTRMEMFUNC_P (target_type)) -- cgit v1.1