PR c++/71718 - infinite recursion and alias template
authorJason Merrill <jason@redhat.com>
Fri, 15 Jul 2016 18:37:56 +0000 (14:37 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 15 Jul 2016 18:37:56 +0000 (14:37 -0400)
* pt.c (push_tinst_level_loc): Set at_eof before fatal_error.

From-SVN: r238387

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C [new file with mode: 0644]

index 81f0a24ec457eca5f26718686a7fd03329485dfa..1ef3812a82fe9be4e85b1f2e2f6966d32c9724d3 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-15  Jason Merrill  <jason@redhat.com>
 
+       PR c++/71718
+       * pt.c (push_tinst_level_loc): Set at_eof before fatal_error.
+
        PR c++/70824
        * init.c (constant_value_1): Don't instantiated DECL_INITIAL of
        artificial variables.
index a1b0ca9a85858cb2293d95a54afc25cec9683f01..73b53e23b4d68fbc9bfc7423ce89ca13987a9d04 100644 (file)
@@ -9132,6 +9132,8 @@ push_tinst_level_loc (tree d, location_t loc)
 
   if (tinst_depth >= max_tinst_depth)
     {
+      /* Tell error.c not to try to instantiate any templates.  */
+      at_eof = 2;
       fatal_error (input_location,
                   "template instantiation depth exceeds maximum of %d"
                    " (use -ftemplate-depth= to increase the maximum)",
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C
new file mode 100644 (file)
index 0000000..c6d7ae6
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/71718
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+class A : T{};
+
+template <typename T>
+using sp = A<T>;
+
+struct Base {};
+
+template <typename T, int num = 1>
+const sp<T>
+rec()                  // { dg-error "depth" }
+{
+  return rec<T, num - 1>();  
+}
+
+static void f(void) {
+  rec<Base>();
+}
+
+// { dg-prune-output "compilation terminated" }