diff options
author | Marek Polacek <polacek@redhat.com> | 2018-01-31 15:37:18 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-01-31 15:37:18 +0000 |
commit | 4ecd9c156cb6a4d67d59563b73cccfd0d5045a50 (patch) | |
tree | c85e6710189647911c02e68ca5c60fe4855be851 | |
parent | bcec133fa9b1f65adcb68dbf7c9794019ddb66f3 (diff) | |
download | gcc-4ecd9c156cb6a4d67d59563b73cccfd0d5045a50.zip gcc-4ecd9c156cb6a4d67d59563b73cccfd0d5045a50.tar.gz gcc-4ecd9c156cb6a4d67d59563b73cccfd0d5045a50.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/cp-gimplify.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/diagnostic/pr84138.C | 8 |
4 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ceb1e85..f89f3ce 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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> PR c++/84091 - ICE with local class in lambda in template. diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 2185925..55a9d27 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -2356,6 +2356,7 @@ cp_fold (tree x) /* 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. */ if (TREE_CODE (x) != code + && x != error_mark_node && !useless_type_conversion_p (TREE_TYPE (org_x), TREE_TYPE (x))) x = fold_convert (TREE_TYPE (org_x), x); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a2ca981..27c5685 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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> PR fortran/78534 diff --git a/gcc/testsuite/g++.dg/diagnostic/pr84138.C b/gcc/testsuite/g++.dg/diagnostic/pr84138.C new file mode 100644 index 0000000..5c48b9b --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr84138.C @@ -0,0 +1,8 @@ +// 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" } |