On Tue, 12 Aug 2014, Thomas Preud'homme wrote:
As mentioned in PR60070, there is many cases when a programmer want to
ensure that a program does not use any floating point data type. Other
cases to consider is when a target has several floating point ABI and
user want to ensure his/her is compatible with all available floating
point ABI. Adding such a check also provides an opportunity to adapt
the behavior of the compiler based on its result.
This patch adds the new option -fno-float to request gcc to throw an
error if any float or floating point operation is involved. The patch
modifies the C and C++ frontend (others could be modified later if
people request it) so as to throw an error whenever a keyword
introducing a float type or a float litteral are encountered. The
check is added to frontend rather middle end as this allow to do the
detection as the file is parsed rather than needing a pass. It also
limit the check to only the place where a float can be declared
instead of having to look at all gimple stmts. Finally, it allows to
catch some cases that would be absent of the middle end due to
simplification or limited folding that the front end might do. Note
though that things excluded by the preprocessor (think #ifdef) would
not be analyzed.
Are you sure you want something that strict? If there are floats in the
code but the compiler manages to get rid of them, it won't cause any
trouble with the ABI. Besides, if you #include a header that declares a
function returning a double, but you don't use that function, the
compilation will still fail. And if you only want to forbid float/double
at the source level, grep is a pretty good tool. I can't see a test for
__builtin_sqrt(42). No ObjC?
I am not at all saying the approach is wrong, just making sure that's
what we want.
--
Marc Glisse