This is an archive of the discontinued LLVM Phabricator instance.

[clang] Display error if _Fract fixed point literals overflow
Needs ReviewPublic

Authored by gousemoodhin on Aug 26 2020, 9:52 PM.

Details

Reviewers
ebevhan
Summary

Values of a fract type are between -1.0 and +1.0.

Diff Detail

Repository
rC Clang

Event Timeline

gousemoodhin requested review of this revision.Aug 26 2020, 9:52 PM
gousemoodhin created this revision.

This needs a few tests.

Testing it myself also shows that

unsigned _Fract f = 1.0ur;

seems to get an error, which it shouldn't.

This needs a few tests.

Testing it myself also shows that

unsigned _Fract f = 1.0ur;

seems to get an error, which it shouldn't.

Update:
Compiler makes overflow decision inside function GetFixedPointValue() - LiteralSupport.cpp

Case unsigned _Fract f = 1.0ur;

At LiteralSupport.cpp (between line 1149 - 1198)
The "Val" is 65,536, it shouldn't.
It causes overflow.

Checking how to handle cases like

unsigned _Fract f = 1.0ur;
unsigned _Fract f = 1.01ur;