From 896e460dc8146bc9a39296ea72f320fe3db28cee Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 18 Jun 2019 11:58:25 -0700 Subject: Fix bug in handling of `h` literal suffix. (#990) A literal like: 2.0h is supposed to default to `half` precision, but there was a typo in our logic that meant that the `half` case was mistakenly checking for `l` and not `h` and so it would never trigger (because the `double` case right before it was checking for `l` first), and certainly wouldn't trigger on an `h`. There was also a bug that a literal with `hf`: 2.0hf would go into the path for the `f` suffix without considering the `h`. These changes really ought to have some tests for them, but this was also just a quick issue I noticed while working on something else. --- source/slang/slang-parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index bb70347c9..aff1d832d 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4044,7 +4044,7 @@ namespace Slang suffixType = parser->getSession()->getErrorType(); } // `f` suffix -> `float` - if(fCount == 1 && !lCount) + if(fCount == 1 && !lCount && !hCount) { suffixType = parser->getSession()->getFloatType(); } @@ -4054,7 +4054,7 @@ namespace Slang suffixType = parser->getSession()->getDoubleType(); } // `h` or `hf` suffix on floating-point literal -> `half` - else if(lCount == 1 && (fCount <= 1)) + else if(hCount == 1 && (fCount <= 1)) { suffixType = parser->getSession()->getHalfType(); } -- cgit v1.2.3