[PATCH] D70122: [cmake] Disable GCC 9's -Winit-list-lifetime warning in ArrayRef

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 08:34:27 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c2151bf4c82: [cmake] Disable GCC 9's -Winit-list-lifetime warning in ArrayRef (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D70122?vs=229761&id=230081#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70122

Files:
  llvm/include/llvm/ADT/ArrayRef.h


Index: llvm/include/llvm/ADT/ArrayRef.h
===================================================================
--- llvm/include/llvm/ADT/ArrayRef.h
+++ llvm/include/llvm/ADT/ArrayRef.h
@@ -97,9 +97,19 @@
     /*implicit*/ constexpr ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {}
 
     /// Construct an ArrayRef from a std::initializer_list.
+#if LLVM_GNUC_PREREQ(9, 0, 0)
+// Disable gcc's warning in this constructor as it generates an enormous amount
+// of messages. Anyone using ArrayRef should already be aware of the fact that
+// it does not do lifetime extension.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Winit-list-lifetime"
+#endif
     /*implicit*/ ArrayRef(const std::initializer_list<T> &Vec)
     : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
       Length(Vec.size()) {}
+#if LLVM_GNUC_PREREQ(9, 0, 0)
+#pragma GCC diagnostic pop
+#endif
 
     /// Construct an ArrayRef<const T*> from ArrayRef<T*>. This uses SFINAE to
     /// ensure that only ArrayRefs of pointers can be converted.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70122.230081.patch
Type: text/x-patch
Size: 1044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191119/57ac98c6/attachment.bin>


More information about the llvm-commits mailing list