On 12/31/15 16:49, Jason Merrill wrote:
Maybe disable the fold if parsing_nsdmi()?
thanks. I've applied the attached. Richard, I've augmented the comment about the folding to emphasize the checkingness. nathan
2016-01-05 Nathan Sidwell <nat...@acm.org> gcc/cp/ PR c++/58583 * pt.c (build_non_dependent_expr): Don't try a checking fold when parsing an nsdmi. gcc/testsuite/ PR c++/58583 * g++.dg/cpp0x/nsdmi-template14.C: Adjust test & errors. Index: cp/pt.c =================================================================== --- cp/pt.c (revision 232074) +++ cp/pt.c (working copy) @@ -23416,9 +23416,13 @@ build_non_dependent_expr (tree expr) { tree inner_expr; - /* Try to get a constant value for all non-dependent expressions in - order to expose bugs in *_dependent_expression_p and constexpr. */ - if (flag_checking && cxx_dialect >= cxx11) + /* When checking, try to get a constant value for all non-dependent + expressions in order to expose bugs in *_dependent_expression_p + and constexpr. */ + if (flag_checking && cxx_dialect >= cxx11 + /* Don't do this during nsdmi parsing as it can lead to + unexpected recursive instantiations. */ + && !parsing_nsdmi ()) fold_non_dependent_expr (expr); /* Preserve OVERLOADs; the functions must be available to resolve Index: testsuite/g++.dg/cpp0x/nsdmi-template14.C =================================================================== --- testsuite/g++.dg/cpp0x/nsdmi-template14.C (revision 232074) +++ testsuite/g++.dg/cpp0x/nsdmi-template14.C (working copy) @@ -1,11 +1,13 @@ // PR c++/58583 // { dg-do compile { target c++11 } } -template<int> struct A // { dg-error "has been parsed" } +template<int> struct A { - int i = (A<0>(), 0); // { dg-error "has been parsed" } + int i = (A<0>(), 0); // { dg-error "recursive instantiation of non-static data" } }; +A<0> a; + template<int N> struct B { B* p = new B<N>; // { dg-error "recursive instantiation of non-static data" }