diff options
author | Mark Mitchell <mark@codesourcery.com> | 2008-12-10 01:23:28 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2008-12-10 01:23:28 +0000 |
commit | 248e1b22b25685386d34956368cb80c707a22a2f (patch) | |
tree | 97ac3a7e5ee833b3c762010f7695178c02fc047a /gcc/cp/class.c | |
parent | 3725c2e30240d59b7dfe47da43e2eb5d566b9109 (diff) | |
download | gcc-248e1b22b25685386d34956368cb80c707a22a2f.zip gcc-248e1b22b25685386d34956368cb80c707a22a2f.tar.gz gcc-248e1b22b25685386d34956368cb80c707a22a2f.tar.bz2 |
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
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 28 |
1 files changed, 17 insertions, 11 deletions
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)) |