PR c++/69323 - valid
authorJason Merrill <jason@redhat.com>
Wed, 24 Feb 2016 19:56:03 +0000 (14:56 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 24 Feb 2016 19:56:03 +0000 (14:56 -0500)
* pt.c (instantiate_class_template_1): Set
processing_template_decl before substituting friend_type.

From-SVN: r233681

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

index 764d2a8..8fe4306 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-24  Jason Merrill  <jason@redhat.com>
+
+       PR c++/69323
+       * pt.c (instantiate_class_template_1): Set
+       processing_template_decl before substituting friend_type.
+
 016-02-24  Martin Sebor  <msebor@redhat.com>
 
        PR c++/69912
index 65edfa7..e9cdf6e 100644 (file)
@@ -10180,11 +10180,11 @@ instantiate_class_template_1 (tree type)
                       template <class U> friend class T::C;
 
                     otherwise.  */
+                 /* Bump processing_template_decl in case this is something like
+                    template <class T> friend struct A<T>::B.  */
+                 ++processing_template_decl;
                  friend_type = tsubst (friend_type, args,
                                        tf_warning_or_error, NULL_TREE);
-                 /* Bump processing_template_decl for correct
-                    dependent_type_p calculation.  */
-                 ++processing_template_decl;
                  if (dependent_type_p (friend_type))
                    adjust_processing_template_decl = true;
                  --processing_template_decl;
diff --git a/gcc/testsuite/g++.dg/template/friend61.C b/gcc/testsuite/g++.dg/template/friend61.C
new file mode 100644 (file)
index 0000000..1604f5c
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/69323
+
+template<int VALUE>
+struct Outer
+{
+  struct StupidValueTrick
+  {
+    template<int VAL> friend struct Outer<VAL>::StupidValueTrick;
+  };
+};
+typedef Outer<42>::StupidValueTrick GoodValue;
+GoodValue good;