diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-04-16 08:31:23 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-04-16 08:31:23 +0000 |
commit | c814ac9e69218ffd68b042c77829ea590ba6049a (patch) | |
tree | 51e8eb81cf09dafe21406e801f968cad85230089 | |
parent | ef0e80d23cae8d87167ffeab56f5930da1ddf05d (diff) | |
download | gcc-c814ac9e69218ffd68b042c77829ea590ba6049a.zip gcc-c814ac9e69218ffd68b042c77829ea590ba6049a.tar.gz gcc-c814ac9e69218ffd68b042c77829ea590ba6049a.tar.bz2 |
re PR c++/85112 (ICE with invalid constexpr)
2018-04-16 Paolo Carlini <paolo.carlini@oracle.com>
Jason Merrill <jason@redhat.com>
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 <paolo.carlini@oracle.com>
Jason Merrill <jason@redhat.com>
PR c++/85112
* g++.dg/cpp0x/pr85112.C: New.
Co-Authored-By: Jason Merrill <jason@redhat.com>
From-SVN: r259397
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/convert.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/pr85112.C | 17 |
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a04b68f..3a82dfe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-04-16 Paolo Carlini <paolo.carlini@oracle.com> + Jason Merrill <jason@redhat.com> + + 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 <julia.koval@intel.com> PR target/84413 diff --git a/gcc/convert.c b/gcc/convert.c index 8c8931f..68705f3 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 70d1c3c..8806b95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-04-16 Paolo Carlini <paolo.carlini@oracle.com> + Jason Merrill <jason@redhat.com> + + PR c++/85112 + * g++.dg/cpp0x/pr85112.C: New. + 2018-04-15 Bill Schmidt <wschmidt@linux.ibm.com> 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 0000000..13d25be --- /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; +} |