[libcxx-commits] [PATCH] D119152: [libc++] Implement P0627R6 (Function to mark unreachable code)

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 14 09:25:54 PST 2022


Mordante added inline comments.


================
Comment at: libcxx/test/std/utilities/utility/utility.unreachable/unreachable.compile.pass.cpp:16
+
+// would warn if std::unreachable wasn't marked [[noreturn]] or something similar
+[[noreturn]] void unreachable() { std::unreachable(); }
----------------
ldionne wrote:
> I would like this to be a `.verify.cpp` test instead, with `expected-no-diagnostics`. You can look at e.g. `libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/default.lazy.verify.cpp` for how we do that.
> 
> Otherwise, we're relying on the fact that warnings are turned into errors in the test suite, and I find that to be slightly brittle.
Instead of `expected-no-diagnostics` we can let clang issue a diagnostic and test for that.
Adding something like https://godbolt.org/z/fvzoonv5v will result in a diagnostic.
`ADDITIONAL_COMPILE_FLAGS: -Wunreachable-code` will add the required compiler flag to the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119152



More information about the libcxx-commits mailing list