@@ -9132,10 +9132,12 @@ 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)",
- max_tinst_depth);
+ " (use -ftemplate-depth= to increase the maximum)",
+ max_tinst_depth);
return false;
}
new file mode 100644
@@ -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" }