summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2019-08-03 23:54:29 +0000
committerEric Fiselier <eric@efcs.ca>2019-08-03 23:54:29 +0000
commitfcd549a7d8284a8e7c763fee3da2206acd8cdc4f (patch)
tree59861c49742757d9a123ef9322e56c5890852149
parent44b16bd4a5b20ce8b4e9ef56836123a2038f3670 (diff)
downloadbcm5719-llvm-fcd549a7d8284a8e7c763fee3da2206acd8cdc4f.tar.gz
bcm5719-llvm-fcd549a7d8284a8e7c763fee3da2206acd8cdc4f.zip
Suppress -Wctad-maybe-unsupported on types w/o deduction guides.
There are a handful of standard library types that are intended to support CTAD but don't need any explicit deduction guides to do so. This patch adds a dummy deduction guide to those types to suppress -Wctad-maybe-unsupported (which gets emitted in user code). llvm-svn: 367770
-rw-r--r--libcxx/include/__config9
-rw-r--r--libcxx/include/__mutex_base3
-rw-r--r--libcxx/include/functional3
-rw-r--r--libcxx/include/iterator1
-rw-r--r--libcxx/include/mutex1
-rw-r--r--libcxx/include/shared_mutex1
-rw-r--r--libcxx/include/string_view1
-rw-r--r--libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/implicit_ctad.pass.cpp41
-rw-r--r--libcxx/utils/libcxx/test/config.py1
9 files changed, 60 insertions, 1 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index e49adb4d63a..a8991c37056 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1429,6 +1429,15 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_UNUSED_VAR(x) ((void)(x))
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+#define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
+ template <class _Tag = void> \
+ _ClassName(typename _Tag::__allow_ctad) -> _ClassName<void>
+#else
+#define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
+ static_assert(true, "")
+#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+
#endif // __cplusplus
#endif // _LIBCPP_CONFIG
diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base
index f828beaf780..6361c2088b7 100644
--- a/libcxx/include/__mutex_base
+++ b/libcxx/include/__mutex_base
@@ -107,6 +107,8 @@ private:
lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE;
lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard);
+
template <class _Mutex>
class _LIBCPP_TEMPLATE_VIS unique_lock
@@ -205,6 +207,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
template <class _Mutex>
void
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 865a28123b9..dd65f1bc70e 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -3067,7 +3067,8 @@ private:
_ForwardIterator __first_;
_ForwardIterator __last_;
_BinaryPredicate __pred_;
- };
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(default_searcher);
#endif // _LIBCPP_STD_VER > 14
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index 30801ea83db..b503f157b1e 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -841,6 +841,7 @@ public:
_LIBCPP_INLINE_VISIBILITY back_insert_iterator& operator++() {return *this;}
_LIBCPP_INLINE_VISIBILITY back_insert_iterator operator++(int) {return *this;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(back_insert_iterator);
template <class _Container>
inline _LIBCPP_INLINE_VISIBILITY
diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index 20c3ffc38b6..a7d6232a724 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -546,6 +546,7 @@ private:
_MutexTuple __t_;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
#endif // _LIBCPP_STD_VER > 14
#endif // !_LIBCPP_HAS_NO_THREADS
diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex
index fcafd8c0f44..c9911340ea1 100644
--- a/libcxx/include/shared_mutex
+++ b/libcxx/include/shared_mutex
@@ -430,6 +430,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const _NOEXCEPT {return __m_;}
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);
template <class _Mutex>
void
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 04448312ff3..39ebc669744 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -604,6 +604,7 @@ private:
const value_type* __data;
size_type __size;
};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view);
// [string.view.comparison]
diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/implicit_ctad.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/implicit_ctad.pass.cpp
new file mode 100644
index 00000000000..7c4ba6a6c29
--- /dev/null
+++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/implicit_ctad.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcpp-no-deduction-guides
+
+// class back_insert_iterator.
+
+#include <string>
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include <cstddef>
+#include <functional>
+
+#include "test_macros.h"
+
+int main(int, char**)
+{
+ {
+ std::string s;
+ std::back_insert_iterator bs(s);
+ ASSERT_SAME_TYPE(decltype(bs), std::back_insert_iterator<std::string>);
+ }
+ {
+ std::vector<int> v;
+ std::back_insert_iterator bv(v);
+ std::back_insert_iterator cp(bv);
+ ASSERT_SAME_TYPE(decltype(bv), std::back_insert_iterator<std::vector<int>>);
+ ASSERT_SAME_TYPE(decltype(cp), std::back_insert_iterator<std::vector<int>>);
+ }
+
+ return 0;
+}
diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index 82951b76545..6552d30a1c3 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -911,6 +911,7 @@ class Configuration(object):
self.cxx.addWarningFlagIfSupported('-Wunused-variable')
self.cxx.addWarningFlagIfSupported('-Wunused-parameter')
self.cxx.addWarningFlagIfSupported('-Wunreachable-code')
+ self.cxx.addWarningFlagIfSupported('-Wctad-maybe-unsupported')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
# The '#define static_assert' provided by libc++ in C++03 mode
OpenPOWER on IntegriCloud