[clang] da2f852 - [AST] Fix certain consteval assignment and comma operator issues with fixed-point types.
Bevin Hansson via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 04:42:04 PDT 2020
Author: Bevin Hansson
Date: 2020-06-26T13:38:11+02:00
New Revision: da2f852e1913a16a1c6940ce3d3e47158ae5ba0e
URL: https://github.com/llvm/llvm-project/commit/da2f852e1913a16a1c6940ce3d3e47158ae5ba0e
DIFF: https://github.com/llvm/llvm-project/commit/da2f852e1913a16a1c6940ce3d3e47158ae5ba0e.diff
LOG: [AST] Fix certain consteval assignment and comma operator issues with fixed-point types.
Summary:
Assignment and comma operators for fixed-point types were being constevaled as other
binary operators, but they need special treatment.
Reviewers: rjmccall, leonardchan, bjope
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73189
Added:
clang/test/Frontend/fixed_point_crash.c
Modified:
clang/lib/AST/ExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 35b5bad677a0..ebe09c99429f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12920,6 +12920,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
}
bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
+ if (E->isPtrMemOp() || E->isAssignmentOp() || E->getOpcode() == BO_Comma)
+ return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
+
const Expr *LHS = E->getLHS();
const Expr *RHS = E->getRHS();
FixedPointSemantics ResultFXSema =
diff --git a/clang/test/Frontend/fixed_point_crash.c b/clang/test/Frontend/fixed_point_crash.c
new file mode 100644
index 000000000000..12dc1944f018
--- /dev/null
+++ b/clang/test/Frontend/fixed_point_crash.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+union a {
+ _Accum x;
+ int i;
+};
+
+int fn1() {
+ union a m;
+ m.x = 5.6k;
+ return m.i;
+}
+
+int fn2() {
+ union a m;
+ m.x = 7, 5.6k; // expected-warning {{expression result unused}}
+ return m.x, m.i; // expected-warning {{expression result unused}}
+}
+
+_Accum acc = (0.5r, 6.9k); // expected-warning {{expression result unused}}
More information about the cfe-commits
mailing list