[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
Mon Nov 18 00:57:43 PST 2019


labath updated this revision to Diff 229761.
labath added a comment.
Herald added a subscriber: dexonsmith.

- disable the warning just in the ArrayRef constructor


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 __GNUC__ >= 9
+// 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 __GNUC__ >= 9
+#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.229761.patch
Type: text/x-patch
Size: 1020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191118/6e4693df/attachment.bin>


More information about the llvm-commits mailing list