re PR c++/56155 ([C++11] enumeration with fixed underlying type - enumerators have wrong type within enumerator-list)
PR c++/56155 * decl.c (build_enumerator): Always convert the value to a fixed underlying type. From-SVN: r196022
This commit is contained in:
parent
78a2ea4199
commit
d0d9cf0ebf
@ -1,5 +1,9 @@
|
|||||||
2013-02-13 Jason Merrill <jason@redhat.com>
|
2013-02-13 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/56155
|
||||||
|
* decl.c (build_enumerator): Always convert the value to a
|
||||||
|
fixed underlying type.
|
||||||
|
|
||||||
PR c++/56135
|
PR c++/56135
|
||||||
* pt.c (tsubst_copy_and_build): Don't forget any new
|
* pt.c (tsubst_copy_and_build): Don't forget any new
|
||||||
captures that arose from use of dependent names.
|
captures that arose from use of dependent names.
|
||||||
|
@ -12786,15 +12786,14 @@ incremented enumerator value is too large for %<long%>");
|
|||||||
does not fit, the program is ill-formed [C++0x dcl.enum]. */
|
does not fit, the program is ill-formed [C++0x dcl.enum]. */
|
||||||
if (ENUM_UNDERLYING_TYPE (enumtype)
|
if (ENUM_UNDERLYING_TYPE (enumtype)
|
||||||
&& value
|
&& value
|
||||||
&& TREE_CODE (value) == INTEGER_CST
|
&& TREE_CODE (value) == INTEGER_CST)
|
||||||
&& !int_fits_type_p (value, ENUM_UNDERLYING_TYPE (enumtype)))
|
|
||||||
{
|
{
|
||||||
error ("enumerator value %E is too large for underlying type %<%T%>",
|
if (!int_fits_type_p (value, ENUM_UNDERLYING_TYPE (enumtype)))
|
||||||
value, ENUM_UNDERLYING_TYPE (enumtype));
|
error ("enumerator value %E is too large for underlying type %<%T%>",
|
||||||
|
value, ENUM_UNDERLYING_TYPE (enumtype));
|
||||||
|
|
||||||
/* Silently convert the value so that we can continue. */
|
/* Convert the value to the appropriate type. */
|
||||||
value = perform_implicit_conversion (ENUM_UNDERLYING_TYPE (enumtype),
|
value = convert (ENUM_UNDERLYING_TYPE (enumtype), value);
|
||||||
value, tf_none);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
gcc/testsuite/g++.dg/cpp0x/enum22.C
Normal file
12
gcc/testsuite/g++.dg/cpp0x/enum22.C
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// PR c++/56155
|
||||||
|
// { dg-do compile { target c++11 } }
|
||||||
|
|
||||||
|
enum e_ : unsigned char { Z_, E_=sizeof(Z_) };
|
||||||
|
static_assert( E_ == 1, "E_ should be 1");
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct A {
|
||||||
|
enum e_ : unsigned char { Z_, E_=sizeof(Z_) };
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert ( A<double>::E_ == 1, "E_ should be 1");
|
Loading…
Reference in New Issue
Block a user