summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0325-PR-c-48884.patch
blob: 3eccc8622f118218e0cbe9a0365c9eba1a5934ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From 40c44f13de1ac037a120636d569933155f5e5af7 Mon Sep 17 00:00:00 2001
From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 25 May 2011 01:08:46 +0000
Subject: [PATCH] 	PR c++/48884
 	* pt.c (fn_type_unification): Disable access control during
 	substitution.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174163 138bc75d-0d04-0410-961f-82ee72b054a4

index c8eb1d5..e7040c1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -13743,7 +13743,9 @@ fn_type_unification (tree fn,
         incomplete = NUM_TMPL_ARGS (explicit_targs) != NUM_TMPL_ARGS (targs);
 
       processing_template_decl += incomplete;
+      push_deferring_access_checks (dk_no_check);
       fntype = tsubst (fntype, converted_args, tf_none, NULL_TREE);
+      pop_deferring_access_checks ();
       processing_template_decl -= incomplete;
 
       if (fntype == error_mark_node)
@@ -13830,7 +13832,10 @@ fn_type_unification (tree fn,
        substitution results in an invalid type, as described above,
        type deduction fails.  */
     {
-      tree substed = tsubst (TREE_TYPE (fn), targs, tf_none, NULL_TREE);
+      tree substed;
+      push_deferring_access_checks (dk_no_check);
+      substed = tsubst (TREE_TYPE (fn), targs, tf_none, NULL_TREE);
+      pop_deferring_access_checks ();
       if (substed == error_mark_node)
 	return 1;
 
new file mode 100644
index 0000000..8414c43
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/access21.C
@@ -0,0 +1,23 @@
+// PR c++/48884
+
+class X
+{
+  static const int I = 42;
+  friend struct Y;
+};
+
+template <int I> struct A { };
+
+struct Y
+{
+  template <typename T>
+  static A<T::I> f(T t)
+  {
+    return A<T::I>();
+  }
+};
+
+int main()
+{
+  Y::f(X());
+}
diff --git a/gcc/testsuite/g++.dg/template/access22.C b/gcc/testsuite/g++.dg/template/access22.C
new file mode 100644
index 0000000..9ee28a2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/access22.C
@@ -0,0 +1,15 @@
+template <int I> struct B { };
+
+template <class T>
+B<T::I> f();
+
+class A
+{
+  static const int I = 42;
+  template <class T> friend B<T::I> f();
+};
+
+int main()
+{
+  f<A>();
+}
-- 
1.7.0.4