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/testsuite/g++.dg | |
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/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/overload/defarg2.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/overload/defarg3.C | 15 |
2 files changed, 32 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/overload/defarg2.C b/gcc/testsuite/g++.dg/overload/defarg2.C new file mode 100644 index 0000000..6b1a423 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/defarg2.C @@ -0,0 +1,17 @@ +// PR c++/37391 +// { dg-do compile } + +class C { +private: + static int f(int); + static int f(char); + +public: + static void g(int (*)(int) = f); +}; + +void h() { + /* Although C::f is inaccessible here, it is accessible in the + context of C::g, so there is no error. */ + C::g(); +} diff --git a/gcc/testsuite/g++.dg/overload/defarg3.C b/gcc/testsuite/g++.dg/overload/defarg3.C new file mode 100644 index 0000000..83ee111 --- /dev/null +++ b/gcc/testsuite/g++.dg/overload/defarg3.C @@ -0,0 +1,15 @@ +// PR c++/37391 +// { dg-do compile } + +class C { +private: + static int f(int); // { dg-error "private" } + static int f(char); +}; + +class D { +public: + /* C::f is inaccessible, so this is an error, even if this function + is never called. */ + static void g(int (*)(int) = C::f); // { dg-error "context" } +}; |