aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-07-27 17:06:44 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-07-27 11:06:44 -0600
commite4bbeea27ee88bca0261978ad389f2aff9a6b7fb (patch)
treef125c9ab7545a42ce51f366b544cb0f0564585c2 /gcc
parent254c23d3f40c2832670c90de179630e903755252 (diff)
downloadgcc-e4bbeea27ee88bca0261978ad389f2aff9a6b7fb.zip
gcc-e4bbeea27ee88bca0261978ad389f2aff9a6b7fb.tar.gz
gcc-e4bbeea27ee88bca0261978ad389f2aff9a6b7fb.tar.bz2
PR tree-optimization/86696 - ICE in handle_char_store at gcc/tree-ssa-strlen.c:3332
gcc/ChangeLog: PR tree-optimization/86696 * tree-ssa-strlen.c (get_min_string_length): Handle all integer types, including enums. (handle_char_store): Be prepared for the above function to fail. gcc/testsuite/ChangeLog: PR tree-optimization/86696 * gcc.dg/pr86696.C: New test. From-SVN: r263032
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/pr86696.C30
-rw-r--r--gcc/tree-ssa-strlen.c15
4 files changed, 53 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c2bf139..377ea6c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-07-27 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/86696
+ * tree-ssa-strlen.c (get_min_string_length): Handle all integer
+ types, including enums.
+ (handle_char_store): Be prepared for the above function to fail.
+
2018-07-26 Qing Zhao <qing.zhao@oracle.com>
* builtins.c (inline_expand_builtin_string_cmp): Disable inlining
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 354eee3..3850aaa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-27 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/86696
+ * g++.dg/pr86696.C: New test.
+
2018-07-27 David Malcolm <dmalcolm@redhat.com>
PR tree-optimization/86636
diff --git a/gcc/testsuite/g++.dg/pr86696.C b/gcc/testsuite/g++.dg/pr86696.C
new file mode 100644
index 0000000..c7ce17c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr86696.C
@@ -0,0 +1,30 @@
+/* PR tree-optimization/86696 - ICE in handle_char_store at
+ gcc/tree-ssa-strlen.c
+ { dg-do compile }
+ { dg-options "-O2 -Wall -std=c++11" } */
+
+typedef char a;
+template <typename b> struct c {
+ int d;
+ b e;
+};
+struct f;
+class g {
+public:
+ void h(c<f>);
+};
+enum i {};
+enum j : a { k, l };
+struct f {
+ i m;
+ a n;
+ a o;
+ a p;
+ j family;
+};
+void fn1() {
+ i format{};
+ f info{format, a(), 0, 4, l};
+ g dest;
+ dest.h({format, info});
+}
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index eca88a5..1eaa9c5 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -3150,7 +3150,7 @@ handle_pointer_plus (gimple_stmt_iterator *gsi)
static HOST_WIDE_INT
get_min_string_length (tree rhs, bool *full_string_p)
{
- if (TREE_CODE (TREE_TYPE (rhs)) == INTEGER_TYPE)
+ if (INTEGRAL_TYPE_P (TREE_TYPE (rhs)))
{
if (tree_expr_nonzero_p (rhs))
{
@@ -3315,9 +3315,16 @@ handle_char_store (gimple_stmt_iterator *gsi)
Otherwise, we're storing an unknown value at offset OFFSET,
so need to clip the nonzero_chars to OFFSET. */
bool full_string_p = storing_all_zeros_p;
- HOST_WIDE_INT len = (storing_nonzero_p
- ? get_min_string_length (rhs, &full_string_p)
- : 1);
+ HOST_WIDE_INT len = 1;
+ if (storing_nonzero_p)
+ {
+ /* Try to get the minimum length of the string (or
+ individual character) being stored. If it fails,
+ STORING_NONZERO_P guarantees it's at least 1. */
+ len = get_min_string_length (rhs, &full_string_p);
+ if (len < 0)
+ len = 1;
+ }
location_t loc = gimple_location (stmt);
tree oldlen = si->nonzero_chars;