Commit 4ecd9c15 by Marek Polacek Committed by Marek Polacek

re PR c++/84138 (ICE folding broken constant)

	PR c++/84138
	* cp-gimplify.c (cp_fold): Check if X is an error node before
	calling useless_type_conversion_p.

	* g++.dg/diagnostic/pr84138.C: New test.

From-SVN: r257240
parent bcec133f
2018-01-31 Marek Polacek <polacek@redhat.com>
PR c++/84138
* cp-gimplify.c (cp_fold): Check if X is an error node before
calling useless_type_conversion_p.
2018-01-30 Jason Merrill <jason@redhat.com> 2018-01-30 Jason Merrill <jason@redhat.com>
PR c++/84091 - ICE with local class in lambda in template. PR c++/84091 - ICE with local class in lambda in template.
......
...@@ -2356,6 +2356,7 @@ cp_fold (tree x) ...@@ -2356,6 +2356,7 @@ cp_fold (tree x)
/* A COND_EXPR might have incompatible types in branches if one or both /* A COND_EXPR might have incompatible types in branches if one or both
arms are bitfields. If folding exposed such a branch, fix it up. */ arms are bitfields. If folding exposed such a branch, fix it up. */
if (TREE_CODE (x) != code if (TREE_CODE (x) != code
&& x != error_mark_node
&& !useless_type_conversion_p (TREE_TYPE (org_x), TREE_TYPE (x))) && !useless_type_conversion_p (TREE_TYPE (org_x), TREE_TYPE (x)))
x = fold_convert (TREE_TYPE (org_x), x); x = fold_convert (TREE_TYPE (org_x), x);
......
2018-01-31 Marek Polacek <polacek@redhat.com>
PR c++/84138
* g++.dg/diagnostic/pr84138.C: New test.
2018-01-31 Janne Blomqvist <jb@gcc.gnu.org> 2018-01-31 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/78534 PR fortran/78534
......
// PR c++/84138
char
foo()
{
const int i = 0 = 0; // { dg-error "lvalue required as left operand" }
return 1 ? 0 : (char)i;
} // { dg-warning "control reaches" }
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