http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53524

--- Comment #10 from Lawrence Crowl <crowl at google dot com> 2012-05-30 
17:37:37 UTC ---
(In reply to comment #6)
> The warnings are an unintended effect of my fix for PR16603.
> 
> We warn at the end of the below lines of call.c. At the moment isn't clear to
> me *when* it would actually make sense to warn. Hints?
> 
> ///////////////////////////////////
> 
>   /* [expr.cond]
> 
>      After those conversions, one of the following shall hold:
> 
>      --The second and third operands have the same type; the result  is  of
>        that type.  */
>   if (same_type_p (arg2_type, arg3_type))
>     result_type = arg2_type;
>   /* [expr.cond]
> 
>      --The second and third operands have arithmetic or enumeration
>        type; the usual arithmetic conversions are performed to bring
>        them to a common type, and the result is of that type.  */
>   else if ((ARITHMETIC_TYPE_P (arg2_type)
>         || UNSCOPED_ENUM_P (arg2_type))
>        && (ARITHMETIC_TYPE_P (arg3_type)
>            || UNSCOPED_ENUM_P (arg3_type)))
>     {
>       /* In this case, there is always a common type.  */
>       result_type = type_after_usual_arithmetic_conversions (arg2_type,
>                                  arg3_type);
>       do_warn_double_promotion (result_type, arg2_type, arg3_type,
>                 "implicit conversion from %qT to %qT to "
>                 "match other result of conditional",
>                 input_location);
> 
>       if (TREE_CODE (arg2_type) == ENUMERAL_TYPE
>       && TREE_CODE (arg3_type) == ENUMERAL_TYPE)
>         {
>           if (complain & tf_warning)
>             warning (0, 
>                      "enumeral mismatch in conditional expression: %qT vs 
> %qT",
>                      arg2_type, arg3_type);
>         }

In order to get this error, both arg2 and arg3 must be interpreted as enum
types.  However, in the testcase, we are still in the enum definition, and
we are referring to enumerators in that definition, so at that point the
types of the arguments should be some form of int.  That is, the compiler
should either change the types of the enumerators at the closing brace, or
look through the enumerator's enum type to its underlying type while in
the definition that encloses the enumerator.

Reply via email to