From: Volker Reichelt Date: Wed, 7 Dec 2005 19:32:17 +0000 (+0000) Subject: Backport: X-Git-Tag: releases/gcc-3.4.6~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6516f20f7768ad690c6c19cd774e878d3ad072d5;p=thirdparty%2Fgcc.git Backport: 2005-10-20 Mark Mitchell PR c++/22618 * search.c (accessible_p): Check access in the outermost set of template parameters. * g++.dg/parse/access8.C: New test. From-SVN: r108173 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6d139be49ba4..4f884dba1582 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2005-12-07 Volker Reichelt + + Backport: + 2005-10-20 Mark Mitchell + + PR c++/22618 + * search.c (accessible_p): Check access in the outermost set of + template parameters. + 2005-12-06 Volker Reichelt Backport: diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 0dfdb9229789..c227175b0ca1 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -946,8 +946,12 @@ accessible_p (tree type, tree decl) /* In a template declaration, we cannot be sure whether the particular specialization that is instantiated will be a friend or not. Therefore, all access checks are deferred until - instantiation. */ - if (processing_template_decl) + instantiation. However, PROCESSING_TEMPLATE_DECL is set in the + parameter list for a template (because we may see dependent types + in default arguments for template parameters), and access + checking should be performed in the outermost parameter list. */ + if (processing_template_decl + && (!processing_template_parmlist || processing_template_decl > 1)) return 1; if (!TYPE_P (type)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d8d2b4857d0a..51c272d4c829 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2005-12-07 Volker Reichelt + + Backport: + 2005-10-20 Mark Mitchell + + PR c++/22618 + * g++.dg/parse/access8.C: New test. + 2005-12-06 Volker Reichelt Backport: diff --git a/gcc/testsuite/g++.dg/parse/access8.C b/gcc/testsuite/g++.dg/parse/access8.C new file mode 100644 index 000000000000..badea1c98b73 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/access8.C @@ -0,0 +1,12 @@ +// PR c++/22618 + +class foo +{ + typedef int memfun; // { dg-error "private" } +}; + +template // { dg-error "context" } +struct fm_obj { }; + +template // { dg-error "context" } +struct S {};