[flang-commits] [PATCH] D123285: [flang] add a static assert in CheckUnitNumberInRangeImpl

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Apr 11 00:33:32 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cfa899b87c5: [flang] add a static assert in CheckUnitNumberInRangeImpl (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123285

Files:
  flang/runtime/io-api.cpp


Index: flang/runtime/io-api.cpp
===================================================================
--- flang/runtime/io-api.cpp
+++ flang/runtime/io-api.cpp
@@ -1280,6 +1280,9 @@
 static enum Iostat CheckUnitNumberInRangeImpl(INT unit, bool handleError,
     char *ioMsg, std::size_t ioMsgLength, const char *sourceFile,
     int sourceLine) {
+  static_assert(sizeof(INT) >= sizeof(ExternalUnit),
+      "only intended to be used when the INT to ExternalUnit conversion is "
+      "narrowing");
   if (unit != static_cast<ExternalUnit>(unit)) {
     Terminator oom{sourceFile, sourceLine};
     IoErrorHandler errorHandler{oom};


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123285.421842.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220411/b347bdc9/attachment.bin>


More information about the flang-commits mailing list