From: Paolo Carlini Date: Mon, 16 Apr 2018 08:31:23 +0000 (+0000) Subject: re PR c++/85112 (ICE with invalid constexpr) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c814ac9e69218ffd68b042c77829ea590ba6049a;p=gcc.git re PR c++/85112 (ICE with invalid constexpr) 2018-04-16 Paolo Carlini Jason Merrill PR c++/85112 * convert.c (convert_to_integer_1): Use direct recursion for enumeral types and types with a precision less than the number of bits in their mode. /testsuite 2018-04-16 Paolo Carlini Jason Merrill PR c++/85112 * g++.dg/cpp0x/pr85112.C: New. Co-Authored-By: Jason Merrill From-SVN: r259397 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a04b68f7524..3a82dfec269 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-04-16 Paolo Carlini + Jason Merrill + + PR c++/85112 + * convert.c (convert_to_integer_1): Use direct recursion for + enumeral types and types with a precision less than the number + of bits in their mode. + 2018-04-16 Julia Koval PR target/84413 diff --git a/gcc/convert.c b/gcc/convert.c index 8c8931f40ed..68705f3e9b0 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -741,8 +741,10 @@ convert_to_integer_1 (tree type, tree expr, bool dofold) else if (TREE_CODE (type) == ENUMERAL_TYPE || maybe_ne (outprec, GET_MODE_PRECISION (TYPE_MODE (type)))) { - expr = convert (lang_hooks.types.type_for_mode - (TYPE_MODE (type), TYPE_UNSIGNED (type)), expr); + expr + = convert_to_integer_1 (lang_hooks.types.type_for_mode + (TYPE_MODE (type), TYPE_UNSIGNED (type)), + expr, dofold); return maybe_fold_build1_loc (dofold, loc, NOP_EXPR, type, expr); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 70d1c3c1fad..8806b95bb3f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-04-16 Paolo Carlini + Jason Merrill + + PR c++/85112 + * g++.dg/cpp0x/pr85112.C: New. + 2018-04-15 Bill Schmidt PR testsuite/85326 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr85112.C b/gcc/testsuite/g++.dg/cpp0x/pr85112.C new file mode 100644 index 00000000000..13d25bef132 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr85112.C @@ -0,0 +1,17 @@ +// PR c++/85112 +// { dg-do compile { target c++11 } } + +struct A +{ + int m; + int n : 4; +}; + +int i; // { dg-message "not const" } + +void foo() +{ + constexpr int j = i; // { dg-error "not usable" } + A a; + a.n = j; +}