[clang] [clang] Add zero-initialization for fixed point types (PR #80781)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 5 17:59:30 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (PiJoules)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/80781.diff
2 Files Affected:
- (modified) clang/lib/AST/ExprConstant.cpp (+4)
- (added) clang/test/CodeGenCXX/fixed-point-zero-init.cpp (+9)
``````````diff
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 63453890d9879..089bc2094567f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11427,6 +11427,10 @@ class FixedPointExprEvaluator
return true;
}
+ bool ZeroInitialization(const Expr *E) {
+ return Success(0, E);
+ }
+
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
diff --git a/clang/test/CodeGenCXX/fixed-point-zero-init.cpp b/clang/test/CodeGenCXX/fixed-point-zero-init.cpp
new file mode 100644
index 0000000000000..9a7a6600fe556
--- /dev/null
+++ b/clang/test/CodeGenCXX/fixed-point-zero-init.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: @_ZL1a = internal constant [2 x i32] zeroinitializer
+constexpr _Accum a[2] = {};
+
+void func2(const _Accum *);
+void func() {
+ func2(a);
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/80781
More information about the cfe-commits
mailing list