[all-commits] [llvm/llvm-project] 52e8f5: [SYCL] Diagnose uses of zero length arrays

Mariya Podchishchaeva via All-commits all-commits at lists.llvm.org
Wed Dec 29 04:29:03 PST 2021

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 52e8f58d49e63aaf6f4c1682bb787bcbfd240009
  Author: Mariya Podchishchaeva <mariya.podchishchaeva at intel.com>
  Date:   2021-12-29 (Wed, 29 Dec 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaSYCL.cpp
    M clang/lib/Sema/SemaType.cpp
    A clang/test/SemaSYCL/zero-length-arrays.cpp

  Log Message:
  [SYCL] Diagnose uses of zero length arrays

Adds diagnosing on attempt to use zero length arrays, pointers, refs, arrays
of them and structs/classes containing all of it.
In case a struct/class with zero length array is used this emits a set
of notes pointing out how zero length array got into used struct, like
struct ContainsArr {
  int A[0]; // note: field of illegal type declared here
struct Wrapper {
  ContainsArr F; // note: within field of type ContainsArr declared here
  // ...

// Device code
Wrapper W;
W.use(); // error: zero-length arrays are not permitted

Total deep check of each used declaration may result in double
diagnosing at the same location.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D114080

More information about the All-commits mailing list