aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-12-14 17:26:24 -0500
committerJason Merrill <jason@gcc.gnu.org>2011-12-14 17:26:24 -0500
commitda3265662d023c2db377d881001edc101b4cc9c3 (patch)
tree729abfedb42e63715230e8737c21f24feefcc8ed
parent2f074b08d4b008177d3ed6304fc33932e099e43d (diff)
downloadgcc-da3265662d023c2db377d881001edc101b4cc9c3.zip
gcc-da3265662d023c2db377d881001edc101b4cc9c3.tar.gz
gcc-da3265662d023c2db377d881001edc101b4cc9c3.tar.bz2
re PR c++/51554 (ICE in cp/semantics.c:cxx_eval_indirect_ref with -Wall)
PR c++/51554 * semantics.c (cxx_eval_indirect_ref): Fix sanity check. From-SVN: r182346
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/semantics.c10
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/init/constant1.C17
4 files changed, 31 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6677af3..07816eb 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2011-12-14 Jason Merrill <jason@redhat.com>
+ PR c++/51554
+ * semantics.c (cxx_eval_indirect_ref): Fix sanity check.
+
PR c++/51248
* decl.c (copy_type_enum): Also update variants.
(finish_enum): Allow variants of complete enums.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7e1a396..ef85e45 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7329,9 +7329,15 @@ cxx_eval_indirect_ref (const constexpr_call *call, tree t,
{
tree sub = op0;
STRIP_NOPS (sub);
- if (TREE_CODE (sub) == ADDR_EXPR
- || TREE_CODE (sub) == POINTER_PLUS_EXPR)
+ if (TREE_CODE (sub) == POINTER_PLUS_EXPR)
{
+ sub = TREE_OPERAND (sub, 0);
+ STRIP_NOPS (sub);
+ }
+ if (TREE_CODE (sub) == ADDR_EXPR)
+ {
+ /* We couldn't fold to a constant value. Make sure it's not
+ something we should have been able to fold. */
gcc_assert (!same_type_ignoring_top_level_qualifiers_p
(TREE_TYPE (TREE_TYPE (sub)), TREE_TYPE (t)));
/* DR 1188 says we don't have to deal with this. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e276892..f9d8abd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-12-14 Jason Merrill <jason@redhat.com>
+ PR c++/51554
+ * g++.dg/init/constant1.C: New.
+
PR c++/51248
* g++.dg/other/enum2.C: New.
diff --git a/gcc/testsuite/g++.dg/init/constant1.C b/gcc/testsuite/g++.dg/init/constant1.C
new file mode 100644
index 0000000..386b926
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/constant1.C
@@ -0,0 +1,17 @@
+// PR c++/51554
+
+typedef unsigned char uint8;
+typedef unsigned int uint32;
+
+const uint32 XX[] = { 1, 3, 7 };
+
+const uint8 V[] = {
+ *(((const uint8*)&XX[0]) + 0),
+ *(((const uint8*)&XX[0]) + 1),
+ *(((const uint8*)&XX[0]) + 2),
+ *(((const uint8*)&XX[0]) + 3),
+ *(((const uint8*)&XX[1]) + 0),
+ *(((const uint8*)&XX[1]) + 1),
+ *(((const uint8*)&XX[1]) + 2),
+ *(((const uint8*)&XX[1]) + 3),
+};