This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch] PR 51312
- From: Jason Merrill <jason at redhat dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 07 Aug 2014 09:24:50 -0400
- Subject: Re: [C++ Patch] PR 51312
- Authentication-results: sourceware.org; auth=none
- References: <53E359BC dot 10008 at oracle dot com>
On 08/07/2014 06:49 AM, Paolo Carlini wrote:
+ if (ENUM_UNDERLYING_TYPE (enumtype))
+ value = perform_implicit_conversion_flags
+ (ENUM_UNDERLYING_TYPE (enumtype), value, tf_warning_or_error,
+ LOOKUP_IMPLICIT | LOOKUP_NO_NARROWING);
It seems like doing this unconditionally will suppress this error in
some cases:
+ if (!int_fits_type_p (value, ENUM_UNDERLYING_TYPE (enumtype)))
+ error ("enumerator value %E is outside the range of underlying "
+ "type %<%T%>", value, ENUM_UNDERLYING_TYPE (enumtype));
Maybe only do the conversion above if the expression isn't already an
integer or enumeration?
Jason