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