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
This commit is contained in:
Paolo Carlini 2018-04-16 08:31:23 +00:00 committed by Paolo Carlini
parent ef0e80d23c
commit c814ac9e69
4 changed files with 35 additions and 2 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -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

View file

@ -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;
}