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] |
Hi, This patch fixed c_common_type to follow the sign of the fixed-point type, if the other one has an integer type, in order to match the spec: "Clause 6.3.1.8 - Usual arithmetic conversions, after the conversion rule for conversion to float Otherwise, if one operand has fixed-point type and the other operand has integer type, then no conversions are needed; the result type shall be the fixed-point type." Having this change may cause wrong comparison when mixing unsigned fixed-point type and signed integer type. This issue can be caught by using "-Wsign-compare". Ex: (bug59.c) int test(unsigned _Fract a, int b) { return a > b; } gcc -S bug59.c -Wsign-compare bug59.c:3: warning: comparison between signed and unsigned And, this patch fixed two cases of "lang_hooks.types.type_for_mode()" to pass the saturating flag as the 2nd parameter for fixed-point types. Thanks! Regards, Chao-ying 2007-04-10 Chao-ying Fu <fu@mips.com> * fold-const.c (make_range): For fixed-point modes, we need to pass the saturating flag as the 2nd parameter. * c-typeck.c (c_common_type): Follow the sign of the fixed-point type, if the other one has an integer type. * tree-vect-generic.c (type_for_widest_vector_mode): Add one parameter for the saturating flag. Pass it to type_for_mode for fixed-point types. (expand_vector_operations_1): Pass the saturating flag to type_for_widest_vector_mode.
Attachment:
gcc.diff
Description: gcc.diff
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |