-
- Downloads
c: Fix boolean conversion of floating constant as integer constant expression [PR113776]
My fix for bug 111059 and bug 111911 caused a conversion of a floating constant to boolean to wrongly no longer be considered an integer constant expression, because logic to insert a NOP_EXPR in c_objc_common_truthvalue_conversion for an argument not an integer constant expression itself now took place after rather than before the conversion to bool. In the specific case of casting a floating constant to bool, the result is an integer constant expression even though the argument isn't (build_c_cast deals with ensuring that casts to integer type of anything of floating type more complicated than a single floating constant don't get wrongly treated as integer constant expressions even if they fold to constants), so fix the logic in c_objc_common_truthvalue_conversion to handle that special case. Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/113776 gcc/c * c-typeck.cc (c_objc_common_truthvalue_conversion): Return an integer constant expression for boolean conversion of floating constant. gcc/testsuite/ * gcc.dg/pr113776-1.c, gcc.dg/pr113776-2.c, gcc.dg/pr113776-3.c, gcc.dg/pr113776-4.c: New tests.
Showing
- gcc/c/c-typeck.cc 11 additions, 1 deletiongcc/c/c-typeck.cc
- gcc/testsuite/gcc.dg/pr113776-1.c 5 additions, 0 deletionsgcc/testsuite/gcc.dg/pr113776-1.c
- gcc/testsuite/gcc.dg/pr113776-2.c 4 additions, 0 deletionsgcc/testsuite/gcc.dg/pr113776-2.c
- gcc/testsuite/gcc.dg/pr113776-3.c 7 additions, 0 deletionsgcc/testsuite/gcc.dg/pr113776-3.c
- gcc/testsuite/gcc.dg/pr113776-4.c 6 additions, 0 deletionsgcc/testsuite/gcc.dg/pr113776-4.c
Loading
Please register or sign in to comment