This is the mail archive of the
mailing list for the GCC project.
Re: [C/C++ PATCH] Reorganize c-common.c's convert_and_check
- From: Roger Sayle <roger at eyesopen dot com>
- To: Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 16 Nov 2006 11:50:19 -0700 (MST)
- Subject: Re: [C/C++ PATCH] Reorganize c-common.c's convert_and_check
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
> ! 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
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.