aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-03-21 17:13:06 -0400
committerJason Merrill <jason@gcc.gnu.org>2016-03-21 17:13:06 -0400
commit683b810150a0250e65a7640e183aa4339313b34c (patch)
tree33dafbdaad021e6d8f6cb6b6f4c400b070787d0b /gcc
parent11b6a02e916d12fd619e97b5117211ab097394b2 (diff)
downloadgcc-683b810150a0250e65a7640e183aa4339313b34c.zip
gcc-683b810150a0250e65a7640e183aa4339313b34c.tar.gz
gcc-683b810150a0250e65a7640e183aa4339313b34c.tar.bz2
re PR c++/70285 (ICE on valid code on x86_64-linux-gnu: verify_gimple failed)
PR c++/70285 * cp-gimplify.c (cp_fold) [COND_EXPR]: Handle bit-fields. From-SVN: r234384
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/cp-gimplify.c6
-rw-r--r--gcc/testsuite/g++.dg/other/bitfield5.C15
3 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cd98a53..3912395 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2016-03-21 Jason Merrill <jason@redhat.com>
+
+ PR c++/70285
+ * cp-gimplify.c (cp_fold) [COND_EXPR]: Handle bit-fields.
+
2016-03-18 Jason Merrill <jason@redhat.com>
PR c++/70139
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 6a767fa..9bf2482 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2130,6 +2130,12 @@ cp_fold (tree x)
else
x = fold (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)
+ if (tree type = is_bitfield_expr_with_lowered_type (x))
+ x = fold_convert (type, x);
+
break;
case CALL_EXPR:
diff --git a/gcc/testsuite/g++.dg/other/bitfield5.C b/gcc/testsuite/g++.dg/other/bitfield5.C
new file mode 100644
index 0000000..b8cd4dd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/bitfield5.C
@@ -0,0 +1,15 @@
+// PR c++/70285
+
+int a;
+
+struct S
+{
+ int i:8;
+} b;
+
+int
+fn1 (bool x)
+{
+ (&fn1 ? b.i : a) = 42;
+ return (&fn1 ? b.i : a);
+}