From: Nathan Sidwell Date: Fri, 9 Dec 2016 12:18:36 +0000 (+0000) Subject: re PR c++/78550 (bit field and std::initializer_list) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=32913637718983cf04b8225ee778d5e96ae71d7c;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eaada9bc71a..d2e5f478cc4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-09 Nathan Sidwell + + PR C++/78550 + * convert.c (convert_to_integer_1): Maybe fold conversions to + integral types with fewer bits than its mode. + 2016-12-09 Martin Liska * tree-pretty-print.c (pretty_print_string): Escape non-printable @@ -67,9 +73,8 @@ 2016-12-08 Dmitry Vyukov - * opts.c (finish_options): Enable - -fsanitize-address-use-after-scope only if -fsanitize=address is enabled - (not -fsanitize=kernel-address). + * opts.c (finish_options): Enable -fsanitize-address-use-after-scope + only if -fsanitize=address is enabled (not -fsanitize=kernel-address). * doc/invoke.texi (-fsanitize=kernel-address): Don't say that it enables -fsanitize-address-use-after-scope. 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 843ee9f928d..2f15e89d456 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-09 Nathan Sidwell + + PR c++/78550 + * g++.dg/cpp1y/pr78550.C: New. + 2016-12-09 Paul Thomas PR fortran/44265 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr78550.C b/gcc/testsuite/g++.dg/cpp1y/pr78550.C new file mode 100644 index 00000000000..95596b10d7c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr78550.C @@ -0,0 +1,22 @@ +// { dg-do compile { target c++14 } } + +// PR 78550 ICE with initializer_list and bitfield member + +namespace std +{ + template + struct initializer_list + { + const T *a; + __SIZE_TYPE__ b; + constexpr initializer_list (const T *x, __SIZE_TYPE__ y) : a(x), b(y) { } + }; +} +template +struct A { + A (std::initializer_list); +}; +struct B { + int k : 1; +}; +A a{{0}};