From 9ee2cecc2fd6a0e4e9633f0a4096b87414635c16 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 15 Jul 2016 14:37:56 -0400 Subject: [PATCH] PR c++/71718 - infinite recursion and alias template * pt.c (push_tinst_level_loc): Set at_eof before fatal_error. From-SVN: r238387 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 2 ++ gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 81f0a24..1ef3812 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2016-07-15 Jason Merrill + 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a1b0ca9..73b53e2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 0000000..c6d7ae6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-55.C @@ -0,0 +1,23 @@ +// PR c++/71718 +// { dg-do compile { target c++11 } } + +template +class A : T{}; + +template +using sp = A; + +struct Base {}; + +template +const sp +rec() // { dg-error "depth" } +{ + return rec(); +} + +static void f(void) { + rec(); +} + +// { dg-prune-output "compilation terminated" } -- 2.7.4