[PATCH] D114080: [SYCL] Diagnose uses of zero length arrays

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 17 05:01:33 PST 2021


Fznamznon created this revision.
Herald added subscribers: Naghasan, Anastasia, ebevhan, yaxunl.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds diagnosing on attempt to use zero length arrays, pointers, refs, arrays
of them and structs/classes containing all of it.
A couple of assertions were removed from SemaSYCL because the new
diagnostics are deferred and emitted later than SemaSYCL routines.
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
this:

  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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114080

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaSYCL.cpp
  clang/test/SemaSYCL/zero-length-arrays.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114080.387904.patch
Type: text/x-patch
Size: 12246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211117/911130c0/attachment-0001.bin>


More information about the cfe-commits mailing list