[PATCH] D158615: [clang] Emit an error if variable ends up with incomplete array type

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 28 11:53:03 PDT 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with a small nit



================
Comment at: clang/lib/Sema/SemaDecl.cpp:13453-13466
+    if (!VDeclType->isDependentType() &&
+        Context.getAsIncompleteArrayType(VDeclType)) {
+      if (Init && !Init->getType().isNull() &&
+          !Init->getType()->isDependentType()) {
+        if (Context.getAsIncompleteArrayType(Init->getType())) {
+          // Bail out if it is not possible to deduce array size from the
+          // initializer.
----------------
We can cram everything into one predicate; but this is largely intended to rearrange the logic so we're checking the cheap conditions before trying to call `getAsIncompleteArrayType` twice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158615



More information about the cfe-commits mailing list