Commit ae51fb47 by Paolo Carlini Committed by Paolo Carlini

re PR c++/81061 (ICE modifying read-only variable)

/cp
2017-12-13  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

	PR c++/81061
	* g++.dg/other/const5.C: New.

From-SVN: r255613
parent 5ef54d57
2017-12-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/81061
* typeck.c (cp_build_modify_expr): Upon cxx_readonly_error
immediately return error_mark_node.
2017-12-13 Nathan Sidwell <nathan@acm.org> 2017-12-13 Nathan Sidwell <nathan@acm.org>
PR c++/15272 PR c++/15272
......
...@@ -8037,8 +8037,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, ...@@ -8037,8 +8037,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
{ {
if (complain & tf_error) if (complain & tf_error)
cxx_readonly_error (lhs, lv_assign); 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 /* If storing into a structure or union member, it may have been given a
......
2017-12-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/81061
* g++.dg/other/const5.C: New.
2017-12-13 Alexandre Oliva <aoliva@redhat.com> 2017-12-13 Alexandre Oliva <aoliva@redhat.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
// PR c++/81061
const int i = 0;
void foo()
{
(0, i) = 1; // { dg-error "read-only" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment