]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/23842 (Incorrect access control context)
authorMark Mitchell <mark@codesourcery.com>
Tue, 13 Sep 2005 14:44:08 +0000 (14:44 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 13 Sep 2005 14:44:08 +0000 (14:44 +0000)
PR c++/23842
* pt.c (tsubst_default_argument): Do treat default argument
expressions as occurring in the context of the function called.

PR c++/23842
* g++.dg/template/access16.C: New test.

From-SVN: r104224

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/access16.C [new file with mode: 0644]

index cd19181dafc02c1d4bff6df2b8f60cb66b39160d..e0d24ec3e104233e2db1cda6a5c104b713c8ed95 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23842
+       * pt.c (tsubst_default_argument): Do treat default argument
+       expressions as occurring in the context of the function called. 
+
 2005-09-12  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/23841
index 07054ecf314cbc492ea8b005abf37f43abc8a2ac..bcff043c18881b259051eab34fdf42c009170b59 100644 (file)
@@ -6097,10 +6097,6 @@ tsubst_default_argument (tree fn, tree type, tree arg)
      we must be careful to do name lookup in the scope of S<T>,
      rather than in the current class.  */
   push_access_scope (fn);
-  /* The default argument expression should not be considered to be
-     within the scope of FN.  Since push_access_scope sets
-     current_function_decl, we must explicitly clear it here.  */
-  current_function_decl = NULL_TREE;
   /* The "this" pointer is not valid in a default argument.  */
   if (cfun)
     {
index 37d8a45407bebb9b706be7bdad473d834ae055c8..5322f23a28d786ff4155784ff8b5e04f831937aa 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23842
+       * g++.dg/template/access16.C: New test.
+
 2005-09-13  Richard Sandiford  <richard@codesourcery.com>
 
        * gfortran.dg/char_pack_2.f90: Increase the vector size.
diff --git a/gcc/testsuite/g++.dg/template/access16.C b/gcc/testsuite/g++.dg/template/access16.C
new file mode 100644 (file)
index 0000000..bb7ebcc
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/23842
+
+struct S;
+extern S *p;
+template <class T> int f(T*, int y = ((T*)p)->x) {
+       return y;
+}
+struct S {
+private:
+  int x;
+  template <class U> friend int f(U*, int);
+};
+int g() {
+  return f(p);
+}
+