[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 07:55:17 PDT 2023


eopXD added a comment.

In D153510#4440784 <https://reviews.llvm.org/D153510#4440784>, @aaron.ballman wrote:

> This checking already happens when the declaration is actually *used*, so I question whether we need to do the check at all (declared but unused variables seem like an edge case to me): https://godbolt.org/z/e4Y8qKMrW
>
> What is the behavior of the example I linked with your patch? Do we now issue the diagnostic twice (once on the declaration and again on the use)?

Yes. The missing behavior here is the check when variables are declared and not used. This patch lets the compiler emit error upon declaration.

  $ cat test.c
  #include <riscv_vector.h>
  
  void bar(void) {
    vint64m1_t i64m1;
    (void)i64m1;
  }
  
  
  eopc at sw02:/scratch/eopc/upstream-llvm-project2/build$ bin/clang -march=rv64g_zve32x test.c
  test.c:4:14: error: RISC-V type 'vint64m1_t' (aka '__rvv_int64m1_t') requires the 'zve64x' extension
      4 |   vint64m1_t i64m1;
        |              ^
  test.c:5:9: error: RISC-V type 'vint64m1_t' (aka '__rvv_int64m1_t') requires the 'zve64x' extension
      5 |   (void)i64m1;
        |         ^
  2 errors generated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153510/new/

https://reviews.llvm.org/D153510



More information about the cfe-commits mailing list