aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2010-09-24 18:24:45 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2010-09-24 16:24:45 +0000
commit1d0804d4b6a66182a23ea9df876fb33da0b7d702 (patch)
treea6a227dfae75d1896089bedcef4875d6a83e133d /gcc
parent5642f5d5d5e3f6867cbe4b7b6fb1588365514c9c (diff)
downloadgcc-1d0804d4b6a66182a23ea9df876fb33da0b7d702.zip
gcc-1d0804d4b6a66182a23ea9df876fb33da0b7d702.tar.gz
gcc-1d0804d4b6a66182a23ea9df876fb33da0b7d702.tar.bz2
re PR middle-end/45738 (ICE: tree check: expected var_decl, have debug_expr_decl in const_value_known_p, at varpool.c:375)
PR tree-optimization/45738 PR tree-optimization/45741 * expr.c (string_constant): Allow CONST_DECL too; check that DECL_INITIAL is set. * varpool.c (const_value_known_p): Only look into VAR_DECL and CONST_DECL. * gcc.c-torture/compile/pr45741.c: New. * gfortran.fortran-torture/compile/pr45738.f90: New. From-SVN: r164602
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/expr.c4
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr45771.c7
-rw-r--r--gcc/testsuite/gfortran.fortran-torture/compile/pr45738.f9011
-rw-r--r--gcc/varpool.c4
6 files changed, 39 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 738ae88..ce8050f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-24 Jan Hubicka <jh@suse.cz>
+
+ PR tree-optimization/45738
+ PR tree-optimization/45741
+ * expr.c (string_constant): Allow CONST_DECL too;
+ check that DECL_INITIAL is set.
+ * varpool.c (const_value_known_p): Only look into VAR_DECL
+ and CONST_DECL.
+
2010-09-24 Joseph Myers <joseph@codesourcery.com>
* common.opt (undef): New.
diff --git a/gcc/expr.c b/gcc/expr.c
index 6b56383..7bc1575 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -9854,12 +9854,14 @@ string_constant (tree arg, tree *ptr_offset)
*ptr_offset = fold_convert (sizetype, offset);
return array;
}
- else if (TREE_CODE (array) == VAR_DECL)
+ else if (TREE_CODE (array) == VAR_DECL
+ || TREE_CODE (array) == CONST_DECL)
{
int length;
/* Variables initialized to string literals can be handled too. */
if (!const_value_known_p (array)
+ || !DECL_INITIAL (array)
|| TREE_CODE (DECL_INITIAL (array)) != STRING_CST)
return 0;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8c526d5..e1cd3a1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-24 Jan Hubicka <jh@suse.cz>
+
+ PR tree-optimization/45738
+ PR tree-optimization/45741
+ * gcc.c-torture/compile/pr45741.c: New.
+ * gfortran.fortran-torture/compile/pr45738.f90: New.
+
2010-09-24 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/cpp/undef-opt-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr45771.c b/gcc/testsuite/gcc.c-torture/compile/pr45771.c
new file mode 100644
index 0000000..2bd96ecc
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr45771.c
@@ -0,0 +1,7 @@
+static const int data[2048];
+
+void foo (void *ptr)
+{
+ __builtin_memcmp (data, ptr, 1);
+}
+
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr45738.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr45738.f90
new file mode 100644
index 0000000..b0541e3
--- /dev/null
+++ b/gcc/testsuite/gfortran.fortran-torture/compile/pr45738.f90
@@ -0,0 +1,11 @@
+PROGRAM TestInfinite
+ integer(8) :: bit_pattern_NegInf_i8 = -4503599627370496_8
+
+ integer(8) :: i
+ real(8) :: r
+
+ r = transfer(bit_pattern_NegInf_i8_p,r)
+ i = transfer(r,i)
+
+END PROGRAM TestInfinite
+
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 3ce3bac..673905d 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -367,8 +367,8 @@ const_value_known_p (tree decl)
{
struct varpool_node *vnode;
- if (TREE_CODE (decl) == PARM_DECL
- || TREE_CODE (decl) == RESULT_DECL)
+ if (TREE_CODE (decl) != VAR_DECL
+ &&TREE_CODE (decl) != CONST_DECL)
return false;
if (TREE_CODE (decl) == CONST_DECL