Fix get_target_expr for bit-field expressions.
authorJason Merrill <jason@redhat.com>
Fri, 24 Jun 2016 21:48:14 +0000 (17:48 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 24 Jun 2016 21:48:14 +0000 (17:48 -0400)
* tree.c (get_target_expr_sfinae): Handle bit-fields.
(build_target_expr): Call mark_rvalue_use.

From-SVN: r237773

gcc/cp/ChangeLog
gcc/cp/tree.c

index 78dd88f20b268b9793fb48e0483f454607fed867..a36cbff0a320f2b378972188557b2798a30ce46c 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-24  Jason Merrill  <jason@redhat.com>
+
+       * tree.c (get_target_expr_sfinae): Handle bit-fields.
+       (build_target_expr): Call mark_rvalue_use.
+
 2016-06-24  Jakub Jelinek  <jakub@redhat.com>
 
        * call.c (magic_varargs_p): Return 3 for __builtin_*_overflow_p.
index 6010f63746f058fc6db3ba2b56fa1f67ed962f44..fa8db0afded92be1c19cc7022c11f493d4c15164 100644 (file)
@@ -377,6 +377,8 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
   tree t;
   tree type = TREE_TYPE (decl);
 
+  value = mark_rvalue_use (value);
+
   gcc_checking_assert (VOID_TYPE_P (TREE_TYPE (value))
                       || TREE_TYPE (decl) == TREE_TYPE (value)
                       /* On ARM ctors return 'this'.  */
@@ -729,7 +731,10 @@ get_target_expr_sfinae (tree init, tsubst_flags_t complain)
   else if (TREE_CODE (init) == VEC_INIT_EXPR)
     return build_target_expr (VEC_INIT_EXPR_SLOT (init), init, complain);
   else
-    return build_target_expr_with_type (init, TREE_TYPE (init), complain);
+    {
+      init = convert_bitfield_to_declared_type (init);
+      return build_target_expr_with_type (init, TREE_TYPE (init), complain);
+    }
 }
 
 tree