summaryrefslogtreecommitdiff
path: root/gcc/convert.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@gcc.gnu.org>2016-12-09 12:18:36 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2016-12-09 12:18:36 +0000
commit32913637718983cf04b8225ee778d5e96ae71d7c (patch)
tree2e55f013560430187cd9f24a7fddc5304d96720f /gcc/convert.c
parent345bd7ebbb38f0e1d5acf33ab3f680111cfa7871 (diff)
re PR c++/78550 (bit field and std::initializer_list)
PR c++/78550 * convert.c (convert_to_integer_1): Maybe fold conversions to integral types with fewer bits than its mode. testsuite/ PR c++/78550 * g++.dg/cpp1y/pr78550.C: New. From-SVN: r243479
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/convert.c b/gcc/convert.c
index 8f18ee4d247..54b0a5d8327 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -646,10 +646,11 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
to TYPE. */
else if (TREE_CODE (type) == ENUMERAL_TYPE
|| outprec != GET_MODE_PRECISION (TYPE_MODE (type)))
- return build1 (NOP_EXPR, type,
- convert (lang_hooks.types.type_for_mode
- (TYPE_MODE (type), TYPE_UNSIGNED (type)),
- expr));
+ {
+ expr = convert (lang_hooks.types.type_for_mode
+ (TYPE_MODE (type), TYPE_UNSIGNED (type)), expr);
+ return maybe_fold_build1_loc (dofold, loc, NOP_EXPR, type, expr);
+ }
/* Here detect when we can distribute the truncation down past some
arithmetic. For example, if adding two longs and converting to an