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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 6 05:27:51 PST 2021


aaron.ballman added a comment.

Just a few minor nits from me.



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11395-11396
   InGroup<IgnoredAttributes>;
+def err_sycl_zero_array_size : Error<
+  "zero-length arrays are not permitted in SYCL device code">;
 
----------------
We should reuse `err_typecheck_zero_array_size` and give it a `%select` for the reason the zero-length array is not permitted.


================
Comment at: clang/lib/Sema/SemaSYCL.cpp:76-82
+        if (auto *FD = dyn_cast<FieldDecl>(D)) {
+          SYCLDiagIfDeviceCode(FD->getLocation(),
+                               diag::note_illegal_field_declared_here)
+              << FD->getType()->isPointerType() << FD->getType();
+        } else {
+          SYCLDiagIfDeviceCode(D->getLocation(), diag::note_declared_at);
+        }
----------------
Can elide the braces here per the usual coding conventions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114080



More information about the cfe-commits mailing list