[PATCH] D153510: [Clang] Check type support for local variable declaration
Yueh-Ting (eop) Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 22 01:37:27 PDT 2023
eopXD created this revision.
eopXD added reviewers: craig.topper, aaron.ballman.
Herald added subscribers: luke, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.
The initial intention here is to guard local variable declarations for
RVV types, taking a step back we can reuse checkTypeSupport to avoid
code duplication.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153510
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/riscv-types.c
clang/test/Sema/riscv-vector-float16-check.c
clang/test/Sema/riscv-vector-float32-check.c
clang/test/Sema/riscv-vector-float64-check.c
clang/test/Sema/riscv-vector-int64-check.c
Index: clang/test/Sema/riscv-vector-int64-check.c
===================================================================
--- clang/test/Sema/riscv-vector-int64-check.c
+++ clang/test/Sema/riscv-vector-int64-check.c
@@ -6,3 +6,7 @@
vint64m1_t foo() { /* expected-error {{RISC-V type 'vint64m1_t' (aka '__rvv_int64m1_t') requires the 'zve64x' extension}} */
} /* expected-warning {{non-void function does not return a value}}*/
+
+void bar(void) {
+ vint64m1_t i64m1; /* expected-error {{RISC-V type 'vint64m1_t' (aka '__rvv_int64m1_t') requires the 'zve64x' extension}} */
+}
Index: clang/test/Sema/riscv-vector-float64-check.c
===================================================================
--- clang/test/Sema/riscv-vector-float64-check.c
+++ clang/test/Sema/riscv-vector-float64-check.c
@@ -6,3 +6,7 @@
vfloat64m1_t foo() { /* expected-error {{RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64d' extension}} */
} /* expected-warning {{non-void function does not return a value}}*/
+
+void bar(void) {
+ vfloat64m1_t f64m1; /* expected-error {{RISC-V type 'vfloat64m1_t' (aka '__rvv_float64m1_t') requires the 'zve64d' extension}} */
+}
Index: clang/test/Sema/riscv-vector-float32-check.c
===================================================================
--- clang/test/Sema/riscv-vector-float32-check.c
+++ clang/test/Sema/riscv-vector-float32-check.c
@@ -6,3 +6,7 @@
vfloat32m1_t foo() { /* expected-error {{RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension}} */
} /* expected-warning {{non-void function does not return a value}}*/
+
+void bar(void) {
+ vfloat32m1_t f32m1; /* expected-error {{RISC-V type 'vfloat32m1_t' (aka '__rvv_float32m1_t') requires the 'zve32f' extension}} */
+}
Index: clang/test/Sema/riscv-vector-float16-check.c
===================================================================
--- clang/test/Sema/riscv-vector-float16-check.c
+++ clang/test/Sema/riscv-vector-float16-check.c
@@ -6,3 +6,7 @@
vfloat16m1_t foo() { /* expected-error {{RISC-V type 'vfloat16m1_t' (aka '__rvv_float16m1_t') requires the 'zvfh' extension}} */
} /* expected-warning {{non-void function does not return a value}}*/
+
+void bar(void) {
+ vfloat16m1_t f16m1; /* expected-error {{RISC-V type 'vfloat16m1_t' (aka '__rvv_float16m1_t') requires the 'zvfh' extension}} */
+}
Index: clang/test/Sema/riscv-types.c
===================================================================
--- clang/test/Sema/riscv-types.c
+++ clang/test/Sema/riscv-types.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple riscv64 -target-feature +v -ast-print %s \
-// RUN: | FileCheck %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v \
+// RUN: -target-feature +experimental-zvfh -ast-print %s | FileCheck %s
void bar(void) {
// CHECK: __rvv_int64m1_t x0;
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8769,6 +8769,8 @@
return;
}
}
+
+ checkTypeSupport(T, NewVD->getLocation(), cast<FunctionDecl>(CurContext));
}
/// Perform semantic checking on a newly-created variable
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153510.533508.patch
Type: text/x-patch
Size: 3188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230622/498aeba2/attachment-0001.bin>
More information about the cfe-commits
mailing list