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) {
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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits