[PATCH] D81904: [clang] Do not crash for unsupported fixed point to floating point conversion

Bevin Hansson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 11 08:31:01 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4408fe17f33: [clang] Do not crash for unsupported fixed point to floating point conversion (authored by gousemoodhin, committed by ebevhan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D81904?vs=284232&id=284749#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81904/new/

https://reviews.llvm.org/D81904

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Frontend/fixed_point_errors.c


Index: clang/test/Frontend/fixed_point_errors.c
===================================================================
--- clang/test/Frontend/fixed_point_errors.c
+++ clang/test/Frontend/fixed_point_errors.c
@@ -286,3 +286,8 @@
 
 // Division by zero
 short _Accum div_zero = 4.5k / 0.0lr;  // expected-error {{initializer element is not a compile-time constant}}
+
+void foo(void) {
+  _Accum x = 0.5k;
+  if (x == 0.5) {} // expected-error{{invalid operands to binary expression ('_Accum' and 'double')}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -1125,6 +1125,11 @@
   bool LHSFloat = LHSType->isRealFloatingType();
   bool RHSFloat = RHSType->isRealFloatingType();
 
+  // FIXME: Implement floating to fixed point conversion.(Bug 46268)
+  // Reference N1169 4.1.4 (Type conversion, usual arithmetic conversions).
+  if ((LHSType->isFixedPointType() && RHSFloat) ||
+      (LHSFloat && RHSType->isFixedPointType()))
+    return QualType();
   // If we have two real floating types, convert the smaller operand
   // to the bigger result.
   if (LHSFloat && RHSFloat) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81904.284749.patch
Type: text/x-patch
Size: 1202 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200811/11388992/attachment.bin>


More information about the cfe-commits mailing list