This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C/C++ PATCH] Reorganize c-common.c's convert_and_check


Hi Manuel,

On Thu, 16 Nov 2006, [UTF-8] Manuel López-Ibáñez wrote:
> I must admit that I don't fully understand what you are testing. For
> example, in convert_and_check() you add a big condition at the
> beginning:
>
> !   if (TREE_CODE (expr) == INTEGER_CST
> !       && (TREE_CODE (type) == INTEGER_TYPE
> !         || TREE_CODE (type) == ENUMERAL_TYPE)
> !       && !int_fits_type_p (expr, type))
>
> then later within the body of that condition you test for:
>
> !         else if (pedantic
> !                  && (TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE
> !                      || TYPE_PRECISION (TREE_TYPE (expr))
> !                         != TYPE_PRECISION (type)))
>
> How can TREE_CODE (expr) == INTEGER_CST and TREE_CODE (TREE_TYPE
> (expr)) != INTEGER_TYPE be true at the same time?

The first clue is in the code that you quote above INTEGER_CSTs may
have an ENUMERAL_TYPE.  In fact, INTEGER_CSTs may legitimately have
POINTER_TYPE, REFERENCE_TYPE, BOOLEAN_TYPE, INTEGER_TYPE, OFFSET_TYPE
and ENUMERAL_TYPE.

Indeed prior to http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00702.html
we'd occassionally incorrectly construct INTEGER_CSTs of other types.

I hope this helps.

Roger
--


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]