Hi,
in this simple error recovery regression we ICE during gimplification
after sensible diagnostic about assigning to a read-only location. The
problem can be avoided by simply returning immediately error_mark_node
upon cxx_readonly_error - the rest of the function does the same, ie,
doesn't try to proceed when complain & tf_error. I also noticed that
clang appears to behave in the same way for this error. Tested x86_64-linux.
Thanks, Paolo
////////////////////////
/cp
2017-12-13 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/81061
* typeck.c (cp_build_modify_expr): Upon cxx_readonly_error
immediately return error_mark_node.
/testsuite
2017-12-13 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/81061
* g++.dg/other/const5.C: New.
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 255602)
+++ cp/typeck.c (working copy)
@@ -8037,8 +8037,7 @@ cp_build_modify_expr (location_t loc, tree lhs, en
{
if (complain & tf_error)
cxx_readonly_error (lhs, lv_assign);
- else
- return error_mark_node;
+ return error_mark_node;
}
/* If storing into a structure or union member, it may have been given a
Index: testsuite/g++.dg/other/const5.C
===================================================================
--- testsuite/g++.dg/other/const5.C (nonexistent)
+++ testsuite/g++.dg/other/const5.C (working copy)
@@ -0,0 +1,8 @@
+// PR c++/81061
+
+const int i = 0;
+
+void foo()
+{
+ (0, i) = 1; // { dg-error "read-only" }
+}