Hi,
in this regression we ICE during error recovery, much, much later, in
the middle-end. In order to avoid that it seems to me that we can safely
return NULL_TREE.
I'm also taking the occasion to change a pair of errors to error +
inform (this is also consistent with eg, the explain-once type messages
we have got in do_friend and in resolve_address_of_overloaded_function)
Tested x86_64-linux.
Thanks,
Paolo.
////////////////////
/cp
2014-03-07 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58609
* decl.c (check_initializer): Return NULL_TREE after error;
consistently use inform.
/testsuite
2014-03-07 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58609
* g++.dg/cpp0x/constexpr-ice12.C: New.
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 208406)
+++ cp/decl.c (working copy)
@@ -5809,9 +5809,11 @@ check_initializer (tree decl, tree init, int flags
"member %qD", decl);
if (!explained)
{
- error ("(an out of class initialization is required)");
+ inform (input_location,
+ "(an out of class initialization is required)");
explained = 1;
}
+ return NULL_TREE;
}
return init_code;
Index: testsuite/g++.dg/cpp0x/constexpr-ice12.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-ice12.C (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-ice12.C (working copy)
@@ -0,0 +1,9 @@
+// PR c++/58609
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ static constexpr int&& i = 0; // { dg-error "initialization" }
+};
+
+int j = A::i;